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 ) };
                                                          ^

Reply via email to