Confused about -Wabi with type tag on virtual method

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

 



I have a component which ships a C++ library to be integrated into a larger project. To allow both pieces to upgrade their version of GCC independently, we use -Wabi in the component to warn us away from ABI-incompatibilities.

Since the larger project is currently using GCC 8.3 (devtoolset-8), we have -Wabi=13 in the component. My understanding is that this should warn us if the component uses some construct which requires a *newer* ABI than 13. But the following code (minimal example, type tag dispatch on a virtual function is key here) is warning about a change made in ABI 12:

$ cat abi.cpp
constexpr struct my_tag_t {} my_tag;

struct A
{
  virtual int foo (my_tag_t, int x) = 0;
};

int bar (A &a, int x)
{
  return a.foo(my_tag, x);
}
$ g++-10 -Wabi=13 -c abi.cpp
abi.cpp: In function ‘int bar(A&, int)’:
abi.cpp:10:15: warning: empty class ‘my_tag_t’ parameter passing ABI changes in ‘-fabi-version=12’ (GCC 8) [-Wabi]
   10 |   return a.foo(my_tag, x);
      |          ~~~~~^~~~~~~~~~~

If I force the component to use ABI 11 (-fabi-version-11), the warning goes away. But isn't this the opposite of what I want? Now the component is using the older/incompatible ABI compared to the larger project.

Am I using -Wabi all wrong, or is this perhaps a bug?

As a workaround I can change my virtual function signature to accept "const my_tag_t &". Is this the best approach?

Thanks,

John




[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