[llvm-bugs] [Bug 38964] New: After r336132, <string> can't be compiled by gcc in < c++11 mode

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Sep 16 02:29:19 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=38964

            Bug ID: 38964
           Summary: After r336132, <string> can't be compiled by gcc in <
                    c++11 mode
           Product: libc++
           Version: 7.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: dimitry at andric.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

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

$ echo "#include <string>" | g++ -std=c++03 -nostdinc++ -isystem
/usr/include/c++/v1 -x c++ -c - -o -
In file included from <stdin>: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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180916/5cf74fe5/attachment.html>


More information about the llvm-bugs mailing list