https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64654
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2021-12-17 00:00:00 |2023-4-2
--- Comment #3 from anlauf at gcc dot gnu.org ---
(In reply to kargl from comment #1)
> Reduced testcase.
[...]
> Workaround. Don't compile with -O0. All other optimiziation
> levels -O1, -O2, and -O3 with and without -fcheck=all compile
> and run for gfortran 5.0.
This is no longer true for 13-mainline.
Using -O1 along with -fcheck=bounds leads to a crash on x86_64-pc-linux-gnu,
and -fsanitize=undefined gives at runtime:
pr64654.f90:1:16: runtime error: load of null pointer of type 'integer(kind=4)'
The dump-tree of the subroutine shows why:
void s0 ()
{
master.0.s (1, 0B, 0B, 0);
}
void master.0.s (integer(kind=8) __entry, character(kind=1)[1:.a] * a,
integer(kind=4) * n, integer(kind=8) _a)
{
integer(kind=8) .a;
bitsizetype D.4282;
sizetype D.4283;
.a = MAX_EXPR <(integer(kind=8)) *n, 0>;
D.4282 = (bitsizetype) (sizetype) NON_LVALUE_EXPR <.a> * 8;
D.4283 = (sizetype) NON_LVALUE_EXPR <.a>;
switch (__entry)
{
case 0:;
goto L.2;
case 1:;
goto L.4;
}
I think we need to either check the presence of arguments or move the
pointer dereferences.