This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/22020] New: Poor error message for invalid cast in initializer
- From: "ebotcazou at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Jun 2005 19:21:12 -0000
- Subject: [Bug c/22020] New: Poor error message for invalid cast in initializer
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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