https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102909
--- Comment #3 from Iru Cai <mytbk920423 at gmail dot com> --- Looks like this kind of things are detected in the front-end. The GNAT front-end can warn on the similar things: procedure Main is A : Integer; B : constant Integer := 1; begin A := 0; A := A + B; end Main; $ gcc -O2 -gnatwa -gnatwe -c main.adb main.adb:6:09: warning: possibly useless assignment to "A", value might not be referenced