[PATCH v3] elf: Silence GCC 11/12 false positive warning

Florian Weimer fweimer@redhat.com
Fri Jun 17 06:29:55 GMT 2022


* H. J. Lu via Libc-alpha:

> Silence GCC 11/12 false positive warning with -mavx512f on dl-load.c:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106008
>
> $ gcc -O2 -fPIC -march=x86-64 -mavx512f -S -Wall ...
> dl-load.c: In function ‘_dl_map_object_from_fd.constprop’:
> dl-load.c:1158:30: warning: ‘(((char *)loadcmds.113_68 + _933 + 16))[329406144173384849].mapend’ may be used uninitialized [-Wmaybe-uninitialized]
> ---
>  elf/dl-load.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/elf/dl-load.c b/elf/dl-load.c
> index 2e4a010fc5..400b2b8d7b 100644
> --- a/elf/dl-load.c
> +++ b/elf/dl-load.c
> @@ -1152,10 +1152,19 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
>  	    p_align_max = ph->p_align;
>  	  c->mapoff = ALIGN_DOWN (ph->p_offset, GLRO(dl_pagesize));
>  
> +	  DIAG_PUSH_NEEDS_COMMENT;
> +
> +#if __GNUC_PREREQ (11, 0)
> +	  /* Suppress valid GCC warning:
> +	     ‘(((char *)loadcmds.113_68 + _933 + 16))[329406144173384849].mapend’ may be used uninitialized [-Wmaybe-uninitialized]
> +	   */
> +	  DIAG_IGNORE_NEEDS_COMMENT (11, "-Wmaybe-uninitialized");
> +#endif
>  	  /* Determine whether there is a gap between the last segment
>  	     and this one.  */
>  	  if (nloadcmds > 1 && c[-1].mapend != c->mapstart)
>  	    has_holes = true;
> +	  DIAG_POP_NEEDS_COMMENT;

The commit message says “false positive”, the comment says “valid GCC
warning”.  The comment should mention the PR number, too.

Thanks,
Florian



More information about the Libc-alpha mailing list