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 c++/84701] New: casting to ( typeof(variable) ) gives wrong results


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!

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