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: Marc Glisse <marc dot glisse at inria dot fr>
- 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 13:05:55 +0100 (CET)
- 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>
- Reply-to: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
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