https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90309
Alexandre Duret-Lutz <adl at gnu dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |adl at gnu dot org
--- Comment #6 from Alexandre Duret-Lutz <adl at gnu dot org> ---
Came here to report a similar issue, except without the virtual.
With gcc (Raspbian 8.3.0-6+rpi1) 8.3.0 from Raspbian buster on ARM:
$ cat foo2.cc
struct a
{
int nonempty;
};
struct b
{
typedef unsigned (b::*unsigned_fun)() const;
unsigned_fun fun;
};
struct c: public a, public b
{
c()
{
fun = static_cast<b::unsigned_fun>(&c::get_val);
}
unsigned get_val() const;
};
$ g++ -c -Wall -W foo2.cc
foo2.cc: In constructor ‘c::c()’:
foo2.cc:16:51: warning: left shift of negative value [-Wshift-negative-value]
fun = static_cast<b::unsigned_fun>(&c::get_val);
^
https://gcc.godbolt.org/z/J08QVd
Luckily in the project where this occurs I can simply swap the inheritance
order (public b, public a) to get rid of this warning.