This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCHv4] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]


On Sep 30 2018, Martin Jansa <martin.jansa@gmail.com> wrote:

> @@ -110,7 +111,17 @@ __ieee754_jn (int n, double x)
>  	      case 2: temp = -c - s; break;
>  	      case 3: temp = c - s; break;
>  	      }
> +	    /* With GCC 8 (and older) when compiling with -O the compiler
> +	       warns that the variable 'temp', may be used uninitialized.
> +	       The switch above covers all possible values of n & 3
> +	       but GCC without VRP enabled isn't able to figure out the
> +	       range of possible values is [0,3] as explained in:
> +	       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230
> +	       so it's false ositive with -O1.  */
> +	    DIAG_PUSH_NEEDS_COMMENT;
> +	    DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
>  	    b = invsqrtpi * temp / sqrt (x);
> +	    DIAG_POP_NEEDS_COMMENT;

How about adding __builtin_unreachable instead?  That doesn't add any
code, but helps the compiler seeing the whole picture.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]