This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Why does -Wabi-tag complain when -std=c++03?
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Jeffrey Walton <noloader at gmail dot com>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Thu, 24 Mar 2016 12:42:12 +0000
- Subject: Re: Why does -Wabi-tag complain when -std=c++03?
- Authentication-results: sourceware.org; auth=none
- References: <CAH8yC8kYCmJqN4E5s9KQP1sH+PdV0axg9GuEf8MPeMQs0ede_w at mail dot gmail dot com> <CAH6eHdQYuMxhEJFD_P7GD1UgTy+oL4d_To9zwY8SJ1VRAD7J=w at mail dot gmail dot com> <CAH8yC8=SPMAapcOLo1=z5VpBnF3icoSzOjYZvNqZvkzuJeYYUA at mail dot gmail dot com> <CAH6eHdSSFOqHkpYBDn-GCE_U=hyZjJ0_-aXxENeRwQ=EHm6S0g at mail dot gmail dot com> <CAH8yC8k0m7c8deWa9GomCrCkLdAocwtqWJy7hvWJtgriKVsm7w at mail dot gmail dot com>
On 24 March 2016 at 12:34, Jeffrey Walton <noloader@gmail.com> wrote:
> On Thu, Mar 24, 2016 at 8:29 AM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>> On 24 March 2016 at 12:20, Jeffrey Walton <noloader@gmail.com> wrote:
>>> On Thu, Mar 24, 2016 at 8:10 AM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>>>> On 24 March 2016 at 11:55, Jeffrey Walton wrote:
>>>>> In the test program below, why does -Wabi-tag trigger a warning with
>>>>> the std::string when using -std=c++03?
>>>>
>>>> "Although the changes were made for C++11 conformance, the choice of
>>>> ABI to use is independent of the -std option used to compile your
>>>> code, i.e. for a given GCC build the default value of the
>>>> _GLIBCXX_USE_CXX11_ABI macro is the same for all dialects. This
>>>> ensures that the -std does not change the ABI, so that it is
>>>> straightforward to link C++03 and C++11 code together. "
>>>>
>>>> https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
>>>
>>> Thanks. I recall reading that a couple of days ago. I still don't
>>> quite understand what it means. I'm obviously missing something.
>>>
>>> I guess my knowledge gap is due to _GLIBCXX_USE_CXX11_ABI should apply
>>> to C++11 and above to comply with the newer C++ rules, wrote-on-copy
>>> strings, etc. I don't understand how it effects C++03 and below since
>>> the rules that required the change don't apply.
>>
>> The new std::string and std::list are also valid implementations for C++03.
>
> OK, good. Thanks.
>
> If its a valid implementation, then why is the compiler complaining?
That question doesn't even make sense. GCC's warnings aren't there to
say "this implementation does not conform to the standard".
> What, exactly, is the problem or condition that needs fixing?
It's possible nothing needs fixing, depending on how you want to use
the result. But if you compile with -Wabi-tag then you are asking the
compiler to warn you about places where types with the abi_tag
attribute get used in a context where you might want to add the tag
explicitly.
I'm not sure why it warns for global variables, since they correctly
inherit the tag and so their mangling changes even if you don't add
the tag explicitly.
The most important case where you want the warning is:
struct X {
std::string s;
};
The mangling of X is not affected by whether X::s is the new or old
string, so you might want to add the abi_tag to it when the new ABI is
in effect, so that the mangled name of X is different for different
ABIs.
> This is why I was trying to find the GCC 5.1 docs. I needed to read
> more about -Wabi-tag. But it appears -Wabi-tag is not documented; cf.,
> https://gcc.gnu.org/onlinedocs/gcc-5.1.0/gcc/Warning-Options.html#Warning-Options.
You're looking in the wrong place, try the page that lists all
options, which tells you where to find it:
https://gcc.gnu.org/onlinedocs/gcc-5.1.0/gcc/Option-Summary.html#Option-Summary