[Bug c/22020] New: Poor error message for invalid cast in initializer
ebotcazou at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Sat Jun 11 19:21:00 GMT 2005
Compile
int a;
int b = (int)&a;
short c = (short)&a;
on a 32-bit platform:
eric@linux:~> gcc -S t.c
t.c:3: error: initializer element is not constant
Reading C99 6.6 §7-10, I understand that the compiler is entitled to accept the
first initializer but not the second. However I find the error message not very
helpful, especially in light of the other case.
The Sun Studio compiler issues:
gax% cc -S t.c
"t.c", line 3: an address is not allowed in a constant initializer for an
integral type whose size is smaller than the size of a pointer
which is much nicer.
--
Summary: Poor error message for invalid cast in initializer
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: enhancement
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ebotcazou at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22020
More information about the Gcc-bugs
mailing list