Re: Why does -Wabi-tag complain when -std=c++03?

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

 



On Thu, 24 Mar 2016, Jeffrey Walton wrote:

I'm working on some test cases to try and understand "GCC5 and the
C++11 ABI", http://developerblog.redhat.com/2015/02/05/gcc5-and-the-c11-abi/.

In the test program below, why does -Wabi-tag trigger a warning with
the std::string when using -std=c++03?

It doesn't matter if you are using c++03 or c++17, you are still using the new ABI.

Thanks in advance.

$ gcc --version
gcc (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010


$ cat test.cxx
#include <string>

std::string foo __attribute__ ((visibility ("default")));

Your variable foo is incompatible with a variable foo declared using the old ABI, so it is implicitly tagged. You can explicitly write the abi_tag attribute to acknowledge it and the warning will disappear.

std::string bar __attribute__ ((visibility ("default")));


$ g++ -g3 -O2 -Wabi-tag -shared test.cxx -o test.so
test.cxx:3:13: warning: ‘foo’ inherits the "cxx11" ABI tag that
‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ (used in
its type) has [-Wabi-tag]
std::string foo __attribute__ ((visibility ("default")));
            ^
In file included from /usr/include/c++/5/string:52:0,
                from test.cxx:1:
/usr/include/c++/5/bits/basic_string.h:71:11: note:
‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ declared
here
    class basic_string
          ^
test.cxx:4:13: warning: ‘bar’ inherits the "cxx11" ABI tag that
‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ (used in
its type) has [-Wabi-tag]
std::string bar __attribute__ ((visibility ("default")));
            ^
In file included from /usr/include/c++/5/string:52:0,
                from test.cxx:1:
/usr/include/c++/5/bits/basic_string.h:71:11: note:
‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ declared
here
    class basic_string
          ^


--
Marc Glisse



[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