Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After r336132, <string> can't be compiled by gcc in < c++11 mode #38312

Closed
DimitryAndric opened this issue Sep 16, 2018 · 7 comments
Closed

After r336132, <string> can't be compiled by gcc in < c++11 mode #38312

DimitryAndric opened this issue Sep 16, 2018 · 7 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. wontfix Issue is real, but we can't or won't fix it. Not invalid

Comments

@DimitryAndric
Copy link
Collaborator

Bugzilla Link 38964
Resolution WONTFIX
Resolved on Jul 18, 2019 12:59
Version 7.0
OS All
CC @davidbolvansky,@zmodem,@ldionne,@mclow

Extended Description

Because https://reviews.llvm.org/rL336132 introduces a few function templates with default template arguments, gcc cannot compile anymore, when targeting c++03 or earlier:

$ echo "#include " | g++ -std=c++03 -nostdinc++ -isystem /usr/include/c++/v1 -x c++ -c - -o -
In file included from :1:
/usr/include/c++/v1/string:812:35: error: default template arguments may not be used in function templates without -std=c++11 or -std=gnu++11
basic_string(const _CharT* __s) {
^
/usr/include/c++/v1/string:822:62: error: default template arguments may not be used in function templates without -std=c++11 or -std=gnu++11
basic_string(const _CharT* __s, const _Allocator& __a);
^
/usr/include/c++/v1/string:833:70: error: default template arguments may not be used in function templates without -std=c++11 or -std=gnu++11
basic_string(size_type __n, _CharT __c, const _Allocator& __a);
^
/usr/include/c++/v1/string:844:75: error: default template arguments may not be used in function templates without -std=c++11 or -std=gnu++11
const allocator_type& __a = allocator_type());
^
/usr/include/c++/v1/string:848:45: error: default template arguments may not be used in function templates without -std=c++11 or -std=gnu++11
explicit basic_string(const _Tp& __t);
^
/usr/include/c++/v1/string:852:72: error: default template arguments may not be used in function templates without -std=c++11 or -std=gnu++11
explicit basic_string(const _Tp& __t, const allocator_type& __a);
^
/usr/include/c++/v1/string:875:43: error: default template arguments may not be used in function templates without -std=c++11 or -std=gnu++11
basic_string& operator=(const _Tp& __t)
^

Apparently gcc in c++03 mode does accept class templates with default arguments, but not function templates.

https://reviews.llvm.org/D48616 already stated "I may have stepped on a bug fix for old versions of gcc in C++03 mode - Eric? [ was introduced in r292830 ]", and indeed it looks like this has happened.

@DimitryAndric
Copy link
Collaborator Author

assigned to @mclow

@DimitryAndric
Copy link
Collaborator Author

Btw, this was with gcc 8.2.0, but it also happens with g++ 9.0.0 20180826 (experimental), so I think it is intentional on the part of the gcc authors.

@mclow
Copy link
Contributor

mclow commented Sep 17, 2018

I tried moving the template parameters into function parameters, keeping the enable_if bits. That didn't work - introduced ambiguity.

@mclow
Copy link
Contributor

mclow commented Sep 18, 2018

Partial fix up for review at: https://reviews.llvm.org/D52240

@DimitryAndric
Copy link
Collaborator Author

Hm, this appears to be more difficult than I thought... :)

@mclow
Copy link
Contributor

mclow commented Oct 16, 2018

Committed revision 344616 as a partial fix.

@ldionne
Copy link
Member

ldionne commented Jul 18, 2019

We explicitly do not support GCC in C++03 mode anymore, so I'm closing this as WONTFIX.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@Quuxplusone Quuxplusone added the wontfix Issue is real, but we can't or won't fix it. Not invalid label Jan 20, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. wontfix Issue is real, but we can't or won't fix it. Not invalid
Projects
None yet
Development

No branches or pull requests

4 participants