https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89722
Bug ID: 89722
Summary: [8/9 regression] strange warning: type qualifiers
ignored on cast result type [-Wignored-qualifiers]
Product: gcc
Version: 8.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: chantry.xavier at gmail dot com
Target Milestone: ---
Created attachment 45970
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45970&action=edit
test case
Using g++ (GCC) 8.3.1 20190228.
g++ -Wall -Wextra tstbit-short.cc
2019-03-14 21:23:33 xavier pts/3
tstbit-short.cc: In function ‘int desc_contains(const desc_t*, char)’:
tstbit-short.cc:7:41: warning: type qualifiers ignored on cast result type
[-Wignored-qualifiers]
#define BITMASK_NTH(type_t, n) ((type_t)1 << ((n) & (bitsizeof(type_t) - 1)))
^
tstbit-short.cc:10:41: note: in expansion of macro ‘BITMASK_NTH’
((bits)[(unsigned)(n) / (shift)] op BITMASK_NTH(typeof(*(bits)), n))
^~~~~~~~~~~
tstbit-short.cc:11:29: note: in expansion of macro ‘OP_BIT’
#define TST_BIT(bits, n) OP_BIT(bits, n, bitsizeof(*(bits)), & )
^~~~~~
tstbit-short.cc:19:12: note: in expansion of macro ‘TST_BIT’
return TST_BIT(d->tab, b);
^~~~~~~
This does not seem to occur with gcc, nor with g++ <= 7.
I could not find a workaround.
Clearly I cannot remove the cast : for shifting 32 bits or more, we need to be
on a int64.