This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCHv4] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]
- From: Andreas Schwab <schwab at suse dot de>
- To: Martin Jansa <martin dot jansa at gmail dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Mon, 01 Oct 2018 09:28:00 +0200
- Subject: Re: [PATCHv4] sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]
- References: <20180930220030.GJ1449@jama> <20180930220150.3859-1-Martin.Jansa@gmail.com>
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."