This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug other/58319] New: explicit cast doesn't disable -Wconversion warning.


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]