This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/24063] New: Invalid promotion with -fshort-enums
- From: "Alexander dot Nasonov at db dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Sep 2005 08:14:11 -0000
- Subject: [Bug c++/24063] New: Invalid promotion with -fshort-enums
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following code doesn't compile with -fshort-enums option.
$ cat enum.cpp
enum E { E_value = 32768 };
template<class T1, class T2> struct is_same;
template<class T> struct is_same<T,T> {};
int main()
{
typedef typeof(+E_value) promoted;
is_same<promoted,int> ok;
}
$ g++ enum.cpp
$
$ g++ -fshort-enums enum.cpp
enum.cpp: In function `int main()':
enum.cpp:10: error: aggregate `is_same<main::promoted, int> ok' has incomplete
type and cannot be defined
$
$ g++ -v
Reading specs from /opt/arina/tools/lib/gcc/i686-pc-linux-gnu/3.4.4/specs
Configured with: ../../gcc-3.4.4/configure --prefix=/opt/arina/tools
--disable-nls --with-system-zlib --enable-languages=c++ --enable-threads=posix
--enable-long-long --disable-checking --enable-__cxa_atexit
--enable-version-specific-runtime-libs
--with-gxx-include-dir=/opt/arina/tools/include/g++-3.4.4 --with-libiberty=no
--program-suffix=-3.4.4
Thread model: posix
According to the standard, E should be promoted to int because its the only
value can be represented by int.
Indeed, enum.cpp complies fine without -fshort-enums option.
However, if -fshort-enums option is passed to g++, E gets promoted to unsigned int.
--
Summary: Invalid promotion with -fshort-enums
Product: gcc
Version: 3.4.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Alexander dot Nasonov at db dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24063