This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/84701] New: casting to ( typeof(variable) ) gives wrong results
- From: "jim.avera at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 05 Mar 2018 06:27:55 +0000
- Subject: [Bug c++/84701] New: casting to ( typeof(variable) ) gives wrong results
- Auto-submitted: auto-generated
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!