]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gas/config/tc-m68hc11.c
Avoid undefined behaviour in m68hc11 md_begin
authorAlan Modra <amodra@gmail.com>
Tue, 28 Mar 2023 09:55:26 +0000 (20:25 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 28 Mar 2023 10:34:30 +0000 (21:04 +1030)
commitc61b7b7b8ea5e3a55b4642dade4798e5c896df66
treedb5e3ac4209b78dbad7374778d087e55371102fd
parentd7f0f10189fa83a73d9819e81fd321142c0c6398
Avoid undefined behaviour in m68hc11 md_begin

Given p = A where p is a pointer to some type and A is an array of
that type, then the expression p - 1 + 1 evokes undefined behaviour
according to the C standard.

gcc-13 -fsanitize=address,undefined complains about this, but not
where the undefined behaviour actually occurs at tc-m68hc11.c:646.
Instead you get an error: "tc-m68hc11.c:708:20: runtime error: store
to address 0x62600000016c with insufficient space for an object of
type 'int'".  Which is a lie.  There most definitely is space there.
Oh well, diagnostics are sometimes hard to get right.  The UB is easy
to avoid.

PR 30279
* config/tc-m68hc11.c (md_begin): Avoid undefined pointer
decrement.  Remove unnecessary cast.
gas/config/tc-m68hc11.c