https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84701

            Bug ID: 84701
           Summary: casting to ( typeof(variable) ) gives wrong results
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jim.avera at gmail dot com
  Target Milestone: ---

typedef short foo_t;
foo_t s = -1;  /* FFFF */

unsigned u = (unsigned foo_t)s;     /* result is FFFF */
unsigned u = (unsigned typeof(s))s; /* result is FFFFFFFF */

There is no warning using g++ -Wall -W.   

It would be nice if using typeof(var) in a cast would either work, or cause a
compiler error!

Reply via email to