This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH RFC: Warn about pointer wraparound with -Wstrict-overflow
- From: "Richard Guenther" <richard dot guenther at gmail dot com>
- To: "Ian Lance Taylor" <iant at google dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 8 Apr 2008 10:23:43 +0100
- Subject: Re: PATCH RFC: Warn about pointer wraparound with -Wstrict-overflow
- References: <m31w5hz9mc.fsf@google.com>
On Mon, Apr 7, 2008 at 9:35 PM, Ian Lance Taylor <iant@google.com> wrote:
> I'm testing this patch as a response to
> http://www.kb.cert.org/vuls/id/162289
>
> This patch treats undefined pointer wraparound optimizations as an
> instance of undefined signed overflow optimizations (they are of
> course different, but they seem similar to users not educated in
> standardese). You will get a warning with -Wstrict-overflow, and you
> can disable the optimization with -fno-strict-overflow.
>
> My plan is to backport this patch to the gcc 4.2 and 4.3 branches.
Please leave at least the 4.2 branch alone.
> Any comments or concerns?
+/* True if pointer types have undefined overflow. */
+#define POINTER_TYPE_OVERFLOW_UNDEFINED \
+ (!flag_wrapv && !flag_trapv && flag_strict_overflow)
don't add flag_trapv here, it doesn't make sense.
In general I don't think we should do this. The tests in this stupid
CERT are bogus and I have never seen such. Also this test
will cause many false positives I belive, almost any loop with a
pointer induction variable should be affected.
But of course my complaints about -Wstrict-overflow were unheard
in the past as well ;)
Richard.