This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/22020] Poor error message for invalid cast in constant initializer
- From: "david at gibson dot dropbear dot id dot au" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Jul 2005 12:37:27 -0000
- Subject: [Bug c/22020] Poor error message for invalid cast in constant initializer
- References: <20050611192112.22020.ebotcazou@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From david at gibson dot dropbear dot id dot au 2005-07-28 12:37 -------
This is arguably a real functionality bug, not just a poor diagnostic.
The compiler will refuse to allow such a truncated address as an initializer,
even when the assembler can generate the necessary relocations. For example
compare attachment 9378, which will not compile (on powerpc64) to attachment
9379 which assembles and works as intended.
In a more complex example, if x is a (64-bit) symbol and OFFSET a constant, the
assembler will allow:
y = x - OFFSET
.long y
Whereas the compiler will not allow the equivalent initalizer:
uint32_t x = (uint32_t)((uint64_t)&y - OFFSET);
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22020