[Bug fortran/31279] Uninitialized warning for call-by-reference arguments with known intent(in)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31279 --- Comment #8 from Richard Biener --- The original testcase hides everything behind array descriptors, even with unrolling and vectorization disabled we end up with [local count: 214748368]: parm.0.data = [0]; parm.0.offset = -1; parm.0.dtype.elem_len = 4; MEM [(void *) + 24B] = 1103806595072; parm.0.span = 4; parm.0.dim[0].stride = 1; parm.0.dim[0].lbound = 1; parm.0.dim[0].ubound = 4; atmp.1.data = atmp.1.offset = 0; atmp.1.dtype.elem_len = 4; MEM [(void *) + 24B] = 1103806595072; atmp.1.span = 4; atmp.1.dim[0].stride = 1; atmp.1.dim[0].lbound = 0; atmp.1.dim[0].ubound = 3; _gfortran_cshift0_4 (, , , 0B); the frontend might set the fnspec correctly to r (read-only, even transitively) which we might use here but then the actual use is the intrinsic and the fnspec does not say that the function acrually reads from the uninitialized storage.
[Bug fortran/31279] Uninitialized warning for call-by-reference arguments with known intent(in)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31279 Martin Sebor changed: What|Removed |Added Component|middle-end |fortran --- Comment #7 from Martin Sebor --- GCC added the attributes mentioned in comment #4 under the name access -- see below. Getting the middle end to issue a warning for the cases described in comment #0 should be a matter of the Fortran front end making use of the attribute. $ cat x.c && gcc -S -Wall x.c __attribute__ ((access (read_only, 1))) void f (int*); void g (void) { int x; f (); } x.c: In function ‘g’: x.c:6:3: warning: ‘x’ is used uninitialized [-Wuninitialized] 6 | f (); | ^~ x.c:1:46: note: in a call to ‘f’ declared with attribute ‘access (read_only, 1)’ here 1 | __attribute__ ((access (read_only, 1))) void f (int*); | ^ x.c:5:7: note: ‘x’ declared here 5 | int x; | ^