Re: [PATCH] warn on overflow in calls to allocation functions (bugs 77531 and 78284)

2016-12-09 Thread Jakub Jelinek
On Fri, Dec 09, 2016 at 10:44:17AM -0700, Martin Sebor wrote: > On 12/09/2016 06:26 AM, Andreas Schwab wrote: > >FAIL: gcc.dg/attr-alloc_size-3.c (test for warnings, line 445) > >FAIL: gcc.dg/attr-alloc_size-3.c (test for excess errors) > >Excess errors: >

Re: [PATCH] warn on overflow in calls to allocation functions (bugs 77531 and 78284)

2016-12-09 Thread Martin Sebor
On 12/09/2016 06:26 AM, Andreas Schwab wrote: FAIL: gcc.dg/attr-alloc_size-3.c (test for warnings, line 445) FAIL: gcc.dg/attr-alloc_size-3.c (test for excess errors) Excess errors: /daten/aranym/gcc/gcc-20161209/gcc/testsuite/gcc.dg/attr-alloc_size-3.c:244:3: warning: product '65535 * 65535'

Re: [PATCH] warn on overflow in calls to allocation functions (bugs 77531 and 78284)

2016-12-09 Thread Martin Sebor
On 12/09/2016 02:59 AM, Christophe Lyon wrote: On 9 December 2016 at 00:54, Martin Sebor wrote: +enabled with @option{-Wextra}. So I think we should in the immediate term not enable this in Wextra. However, I think for gcc-8 we should revisit after fixing GCC to be cleaner

Re: [PATCH] warn on overflow in calls to allocation functions (bugs 77531 and 78284)

2016-12-09 Thread Andreas Schwab
FAIL: gcc.dg/attr-alloc_size-3.c (test for warnings, line 445) FAIL: gcc.dg/attr-alloc_size-3.c (test for excess errors) Excess errors: /daten/aranym/gcc/gcc-20161209/gcc/testsuite/gcc.dg/attr-alloc_size-3.c:244:3: warning: product '65535 * 65535' of arguments 1 and 2 exceeds maximum object

Re: [PATCH] warn on overflow in calls to allocation functions (bugs 77531 and 78284)

2016-12-09 Thread Christophe Lyon
On 9 December 2016 at 00:54, Martin Sebor wrote: >>> +enabled with @option{-Wextra}. >> >> So I think we should in the immediate term not enable this in Wextra. >> However, I think for gcc-8 we should revisit after fixing GCC to be >> cleaner WRT alloc-zero. >> >> So disable

Re: [PATCH] warn on overflow in calls to allocation functions (bugs 77531 and 78284)

2016-12-08 Thread Martin Sebor
+enabled with @option{-Wextra}. So I think we should in the immediate term not enable this in Wextra. However, I think for gcc-8 we should revisit after fixing GCC to be cleaner WRT alloc-zero. So disable alloc-zero by default, comment typo and potentially adding the GTY marker to

Re: [PATCH] warn on overflow in calls to allocation functions (bugs 77531 and 78284)

2016-12-07 Thread Jeff Law
On 11/19/2016 05:55 PM, Martin Sebor wrote: gcc-78284.diff PR c/77531 - __attribute__((alloc_size(1,2))) could also warn on multiplication overflow PR c/78284 - warn on malloc with very large arguments gcc/c-family/ChangeLog: PR c/77531 PR c/78284 * c.opt

Re: [PATCH] warn on overflow in calls to allocation functions (bugs 77531 and 78284)

2016-12-02 Thread Jeff Law
On 11/19/2016 05:55 PM, Martin Sebor wrote: The attached update is an attempt to incorporate the feedback I received last week during the discussion of the prerequisite patch to avoid calling alloca(0)​. The important changes are: 1) Add attribute returns_nonnull to __builtin_alloca. This

Re: [PATCH] warn on overflow in calls to allocation functions (bugs 77531 and 78284)

2016-11-20 Thread Martin Sebor
On 11/20/2016 04:56 AM, Bernd Edlinger wrote: Hi, when you add a returns_nonnull to the builtin alloca then this code in tree-vrp.c (gimple_stmt_nonzero_warnv_p) should go away: if (flag_delete_null_pointer_checks && lookup_attribute ("returns_nonnull",

Re: [PATCH] warn on overflow in calls to allocation functions (bugs 77531 and 78284)

2016-11-20 Thread Bernd Edlinger
Hi, when you add a returns_nonnull to the builtin alloca then this code in tree-vrp.c (gimple_stmt_nonzero_warnv_p) should go away: if (flag_delete_null_pointer_checks && lookup_attribute ("returns_nonnull", TYPE_ATTRIBUTES (gimple_call_fntype

Re: [PATCH] warn on overflow in calls to allocation functions (bugs 77531 and 78284)

2016-11-19 Thread Martin Sebor
The attached update is an attempt to incorporate the feedback I received last week during the discussion of the prerequisite patch to avoid calling alloca(0)​. The important changes are: 1) Add attribute returns_nonnull to __builtin_alloca. 2) Prevent calls to alloca(0) from triggering the

Re: [PATCH] warn on overflow in calls to allocation functions (bugs 77531 and 78284)

2016-11-17 Thread Martin Sebor
Attached is an update to the patch that avoids duplicating the -Walloca-larger-than warnings. This version also avoids warning for calls with zero allocation size to functions declared with the returns_nonnull attribute (like libiberty's xmalloc). Since such functions cannot return null there's

Re: [PATCH] warn on overflow in calls to allocation functions (bugs 77531 and 78284)

2016-11-16 Thread Martin Sebor
Attached is an updated version of the patch that also adds attribute alloc_size to the standard allocation built-ins (aligned_alloc, alloca, malloc, calloc, and realloc) and handles alloca. Besides that, I've renamed the option to -Walloc-size-larger-than to make it less similar to

Re: [PATCH] warn on overflow in calls to allocation functions (bugs 77531 and 78284)

2016-11-16 Thread Martin Sebor
On 11/14/2016 01:34 PM, Eric Gallager wrote: On 11/13/16, Martin Sebor wrote: Bug 77531 requests a new warning for calls to allocation functions (those declared with attribute alloc_size(X, Y)) that overflow the computation X * Z of the size of the allocated object. Bug

Re: [PATCH] warn on overflow in calls to allocation functions (bugs 77531 and 78284)

2016-11-14 Thread Eric Gallager
On 11/13/16, Martin Sebor wrote: > Bug 77531 requests a new warning for calls to allocation functions > (those declared with attribute alloc_size(X, Y)) that overflow the > computation X * Z of the size of the allocated object. > > Bug 78284 suggests that detecting and

[PATCH] warn on overflow in calls to allocation functions (bugs 77531 and 78284)

2016-11-13 Thread Martin Sebor
Bug 77531 requests a new warning for calls to allocation functions (those declared with attribute alloc_size(X, Y)) that overflow the computation X * Z of the size of the allocated object. Bug 78284 suggests that detecting and diagnosing other common errors in calls to allocation functions, such