]> git.ipfire.org Git - thirdparty/gcc.git/commit
AVR: target/121277 - Don't load 0x800000 with const __flashx *x = NULL.
authorGeorg-Johann Lay <avr@gjlay.de>
Mon, 28 Jul 2025 19:44:06 +0000 (21:44 +0200)
committerGeorg-Johann Lay <avr@gjlay.de>
Mon, 28 Jul 2025 20:06:08 +0000 (22:06 +0200)
commit089faf54fa96565784ebdd8dfcf9c350c4c3bee5
tree0be62cb02c2027873821f62bcec68dbb859e3912
parenta51bf9e10182cf7ac858db0ea6c5cb11b4f12377
AVR: target/121277 - Don't load 0x800000 with const __flashx *x = NULL.

Converting from generic AS to __flashx used the same rule like
for __memx, which tags RAM (generic AS) locations by setting bit 23.
The justification was that generic isn't a subset of __flashx, though
that lead to surprises with code like const __flashx *x = NULL.

The natural thing to do is to just load 0x000000 in that case,
so that the null pointer works in __flashx as expected.

Apart from that, converting NULL to __flashx (or __flash) no more
raises a -Waddr-space-convert diagnostic.

gcc/
PR target/121277
* config/avr/avr.cc (avr_addr_space_convert): When converting
from generic AS to __flashx, don't set bit 23.
(avr_convert_to_type): Don't -Waddr-space-convert when NULL
is converted to __flashx or to __flash.
gcc/config/avr/avr.cc