Re: Using gcc-6.2 with -std=c++03 switch leads to compile errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 16 December 2016 at 11:00, Jonathan Wakely wrote:
> On 16 December 2016 at 10:04, Edward Diener wrote:
>> I am testing gcc-6.2 with the -std=c++03 switch against some Boost C++ code
>> in a library which does not require c++11 on up support. Without going into
>> the exact code I am seeing a compiler error along the lines of:
>>
>> some_path/some_header_file.hpp:224:20: error: no matching function for call
>> to 'std::pair<int&, std::__cxx11::basic_string<char>&>::pair(int&,
>> std::__cxx11::basic_string<char>&)'
>>
>> This implies that even when the -std=c++03 switch with gcc-6.2 c++11
>> constructs are being internally used.
>
> No it doesn't, see
> https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
>
> Whether the __cxx11 ABI is used or not orthogonal to the -std option.
> It's controlled by a macro. If you compile with
> -D_GLIBCXX_USE_CXX11_ABI=0 you'll see the exact same error without the
> __cxx11 qualification.
>
>> Testing the exact same code with the
>> -std=c++11 switch or with the -std=c++14 switch there are no errors. Does
>> this mean that using gcc-6.2 with -std=c++03 does not work with gcc-6.2, or
>> is there something other compiler switch I must use along with the
>> -std=c++03 switch to be able to compile using gcc-6.2 in c++03 mode ?
>
> There is no other switch, -std=c++03 is all that's needed, and you're
> misinterpreting the error.
>
> I would guess that the code is using std::make_pair with an explicit
> template argument list, which changed meaning between C++03 and C++11,
> so the code is simply not compatible with C++03.

Or it's trying to create a pair of references, which also doesn't work
in C++03, because std::pair only had this constructor:

pair(const T1& x, const T2& y);

So you can't create a std::pair<int&, std::string&> because there's no
way to pass non-const references to the constructor, so there's no way
to initialize the members.

So it looks like the Boost code does in fact require C++11 or later.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux