[Bug other/58319] New: explicit cast doesn't disable -Wconversion warning.
pluto at agmk dot net
gcc-bugzilla@gcc.gnu.org
Thu Sep 5 08:09:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58319
Bug ID: 58319
Summary: explicit cast doesn't disable -Wconversion warning.
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
Assignee: unassigned at gcc dot gnu.org
Reporter: pluto at agmk dot net
$ cat u.cpp
struct X { unsigned field : 31; };
int main()
{
unsigned u = 0u;
X x = { .field = static_cast< typeof( X::field ) >( u ) };
return x.field;
}
$ g++ u.cpp -c -Wconversion
u.cpp: In function ‘int main()’:
u.cpp:6:58: warning: conversion to ‘unsigned int:31’ from ‘unsigned int’ may
alter its value [-Wconversion]
X x = { .field = static_cast< typeof( X::field ) >( u ) };
^
More information about the Gcc-bugs
mailing list