[PATCH] use EVRP in more strlen functions

2019-10-28 Thread Martin Sebor
While testing the patch for PR 92226 I posted earlier today I ran into a few cases where I expected the strlen range optimization to take place but it didn't. In other instances this wouldn't be surprising because the optimization was only introduced for multi-character stores and with the expect

Re: [PATCH] use EVRP in more strlen functions

2019-10-28 Thread Martin Sebor
On 10/28/19 4:44 PM, Jeff Law wrote: On 10/28/19 4:36 PM, Martin Sebor wrote: While testing the patch for PR 92226 I posted earlier today I ran into a few cases where I expected the strlen range optimization to take place but it didn't. In other instances this wouldn't be surprisi

[committed] disable c-c++-common/Warray-bounds-4.c to avoid PR 83543

2019-10-29 Thread Martin Sebor
Some of the string tests I've been adding have a tendency to fail on some targets as a result of PR 83543 which prevents GCC from determining the length of constant strings used to initialize local aggregates over some size (the size varies from target to target). I tend to forget about this beca

Re: [PATCH] bring -Warray-bounds closer to -Wstringop-overflow (PR91647, 91463, 91679)

2019-11-01 Thread Martin Sebor
On 10/31/19 12:54 PM, Jeff Law wrote: On 10/11/19 10:34 AM, Martin Sebor wrote: I've fixed the bug in the attached patch.  The rest can be suppressed by replacing the zero-length arrays with flexible array members but that's just trading one misuse for another.  If the code can'

[PATCH] avoid assuming struct, memebers have constant sizes (PR 92349)

2019-11-04 Thread Martin Sebor
The recent -Warray-bounds enhancement to detect past-the-end accesses to struct members has introduced the assumption that struct members have constant sizes. That assumption is not safe for the GCC VLA member extension. The attached change removes the assumption without attempting to handle pas

[PATCH] avoid folding of invalid indices to compound literals (PR 92341)

2019-11-04 Thread Martin Sebor
While testing some other changes I noticed that -Warray-bounds fails to detect out-of-bounds indices to compound literals such as in: int *p = (int[]){ 1, 2, 3 }; // ... p[3] = 7; This is because SRA transforms such references into accesses to uninitialized scalar variables and also sets t

[PATCH] handle constant size VLAs in -Warray-bounds (PR 82608, 92333)

2019-11-04 Thread Martin Sebor
-Warray-bounds doesn't yet have the logic to detect out-of-bounds indices into dynamically allocated arrays like VLAs because it doesn't track allocation calls. But the warning could detect such errors in accesses to VLAs with constant sizes even without such tracking. The attached patch adds th

[PATCH] tweak component_ref_size to extend -Wzero-length-array-bounds and not ICE (PR 92373)

2019-11-05 Thread Martin Sebor
After considering more instances of the enhanced -Warray-bounds and the new -Wzero-length-array-bounds warnings I realized that there are some where the former is being issued for zero-length arrays but where the latter would be more appropriate. The attached change tweaks the logic in component_

[PATCH] include size and offset in -Wstringop-overflow

2019-11-06 Thread Martin Sebor
The -Wstringop-overflow warnings for single-byte and multi-byte stores mention the amount of data being stored and the amount of space remaining in the destination, such as: warning: writing 4 bytes into a region of size 0 [-Wstringop-overflow=] 123 | *p = 0; | ~~~^~~ note: destinatio

Re: [PATCH] include size and offset in -Wstringop-overflow

2019-11-06 Thread Martin Sebor
On 11/6/19 11:55 AM, Jeff Law wrote: On 11/6/19 11:00 AM, Martin Sebor wrote: The -Wstringop-overflow warnings for single-byte and multi-byte stores mention the amount of data being stored and the amount of space remaining in the destination, such as: warning: writing 4 bytes into a region of

Re: [PATCH] include size and offset in -Wstringop-overflow

2019-11-06 Thread Martin Sebor
On 11/6/19 1:39 PM, Jeff Law wrote: On 11/6/19 1:27 PM, Martin Sebor wrote: On 11/6/19 11:55 AM, Jeff Law wrote: On 11/6/19 11:00 AM, Martin Sebor wrote: The -Wstringop-overflow warnings for single-byte and multi-byte stores mention the amount of data being stored and the amount of space

Re: [PATCH] include size and offset in -Wstringop-overflow

2019-11-06 Thread Martin Sebor
On 11/6/19 2:06 PM, Martin Sebor wrote: On 11/6/19 1:39 PM, Jeff Law wrote: On 11/6/19 1:27 PM, Martin Sebor wrote: On 11/6/19 11:55 AM, Jeff Law wrote: On 11/6/19 11:00 AM, Martin Sebor wrote: The -Wstringop-overflow warnings for single-byte and multi-byte stores mention the amount of data

Re: [PATCH] include size and offset in -Wstringop-overflow

2019-11-08 Thread Martin Sebor
On 11/6/19 2:06 PM, Martin Sebor wrote: On 11/6/19 1:39 PM, Jeff Law wrote: On 11/6/19 1:27 PM, Martin Sebor wrote: On 11/6/19 11:55 AM, Jeff Law wrote: On 11/6/19 11:00 AM, Martin Sebor wrote: The -Wstringop-overflow warnings for single-byte and multi-byte stores mention the amount of data

[PATCH] extend -Wstringop-overflow to allocated objects (PR 91582)

2019-11-08 Thread Martin Sebor
Unless it's used with _FORTIFY_SOURCE, -Wstringop-overflow doesn't consider out-of-bounds accesses to objects allocated by alloca, malloc, other functions declared with attribute alloc_size, or even VLAs with variable bounds. This was a known limitation of the checks (done just before expansion)

Re: [PATCH] include size and offset in -Wstringop-overflow

2019-11-11 Thread Martin Sebor
On 11/11/19 4:30 AM, Bernhard Reutner-Fischer wrote: On 8 November 2019 17:57:51 CET, Martin Sebor wrote: On 11/6/19 2:06 PM, Martin Sebor wrote: On 11/6/19 1:39 PM, Jeff Law wrote: On 11/6/19 1:27 PM, Martin Sebor wrote: On 11/6/19 11:55 AM, Jeff Law wrote: On 11/6/19 11:00 AM, Martin

Re: [RFC] Only warn for maybe-uninitialized SRAed bits in -Wextra (PR 80635)

2019-11-11 Thread Martin Sebor
On 11/8/19 5:41 AM, Martin Jambor wrote: Hi, this patch is an attempt to implement my idea from a previous thread about moving -Wmaybe-uninitialized to -Wextra: https://gcc.gnu.org/ml/gcc-patches/2019-02/msg00220.html Specifically, it attempts to split -Wmaybe-uninitialized into those that are

Re: [RFC] Only warn for maybe-uninitialized SRAed bits in -Wextra (PR 80635)

2019-11-11 Thread Martin Sebor
On 11/11/19 10:29 AM, Martin Jambor wrote: Hi, On Mon, Nov 11 2019, Martin Sebor wrote: On 11/8/19 5:41 AM, Martin Jambor wrote: Hi, this patch is an attempt to implement my idea from a previous thread about moving -Wmaybe-uninitialized to -Wextra: https://gcc.gnu.org/ml/gcc-patches/2019-02

[PATCH] errno can't alias locals (PR 92412)

2019-11-11 Thread Martin Sebor
The conditional in default_ref_may_alias_errno has the function return true even for local variables, implying that locals must be assumed not to have been changed across calls to errno-setting functions like malloc. This leads to both worse code and also false negatives in the strlen pass' detec

[PATCH] track dynamic allocation in strlen (PR 91582)

2019-11-11 Thread Martin Sebor
The attached patch extends the strlen pass to detect out-of-bounds accesses to memory allocated by calls to other allocation functions besides calloc and malloc, as well as VLAs, and user-defined functions declared with attribute alloc_size. There is some overlap with the _FORTIFY_SOURCE detectio

Re: [PATCH] include size and offset in -Wstringop-overflow

2019-11-12 Thread Martin Sebor
On 11/11/19 10:10 PM, Jeff Law wrote: On 11/6/19 3:34 PM, Martin Sebor wrote: On 11/6/19 2:06 PM, Martin Sebor wrote: On 11/6/19 1:39 PM, Jeff Law wrote: On 11/6/19 1:27 PM, Martin Sebor wrote: On 11/6/19 11:55 AM, Jeff Law wrote: On 11/6/19 11:00 AM, Martin Sebor wrote: The -Wstringop

Re: [PATCH] implement -Wrestrict for sprintf (PR 83688)

2019-11-12 Thread Martin Sebor
On 10/31/19 10:31 AM, Jeff Law wrote: On 10/8/19 5:51 PM, Martin Sebor wrote: Attached is a resubmission of the -Wrestrict implementation for the sprintf family of functions.  The original patch was posted in 2017 but never approved.  This revision makes only a few minor changes to the original

Re: [PATCH] implement -Wrestrict for sprintf (PR 83688)

2019-11-12 Thread Martin Sebor
On 11/12/19 10:22 AM, Martin Sebor wrote: Committed in r278098. I thought I'd tested the kernel with the patch before and got no warnings, so having rebuilt it again just now I'm surprised to see the 16 instances below (7 of which are distinct). I'm happy to report that no

Re: [PATCH] include size and offset in -Wstringop-overflow

2019-11-12 Thread Martin Sebor
On 11/12/19 10:54 AM, Jeff Law wrote: On 11/12/19 1:15 AM, Richard Biener wrote: On Tue, Nov 12, 2019 at 6:10 AM Jeff Law wrote: On 11/6/19 3:34 PM, Martin Sebor wrote: On 11/6/19 2:06 PM, Martin Sebor wrote: On 11/6/19 1:39 PM, Jeff Law wrote: On 11/6/19 1:27 PM, Martin Sebor wrote: On

Re: [PATCH] errno can't alias locals (PR 92412)

2019-11-13 Thread Martin Sebor
On 11/12/19 1:04 AM, Richard Biener wrote: On Mon, Nov 11, 2019 at 11:38 PM Martin Sebor wrote: The conditional in default_ref_may_alias_errno has the function return true even for local variables, implying that locals must be assumed not to have been changed across calls to errno-setting

Re: [PATCH] avoid warning on vectorized past-the-end stores (PR 93200)

2020-01-09 Thread Martin Sebor
On 1/9/20 9:24 PM, Jeff Law wrote: On Wed, 2020-01-08 at 17:23 +, Martin Sebor wrote: A recent improvement to the vectorizer (r278334 if my bisection is right) can transform multiple stores to adjacent struct members into single vectorized assignments that write over all the members in a

[PATCH] allow nul-over-nul elimination only for single-byte stores (PR 93213)

2020-01-10 Thread Martin Sebor
The multi-byte store enhancement to the strlen optimization checked sometime last summer didn't take care to prevent the nul-over-nul store elimination of multi-byte assignments. This made it possible for subsequent multi-byte stores of fewer nuls to cause prior larger stores to be eliminated. T

[committed] fix a logic error in attribute access validation (PR 93132)

2020-01-10 Thread Martin Sebor
The attached patch corrects a logic error in the validation of the new attribute access where the code incorrectly expects the human readable representation of the attribute to match the terse internal representation of the positional argument. Committed in ra280124 after bootstrapping it and run

Re: [PATCH] doc: Note that some warnings depend on optimizations (PR 92757)

2020-01-13 Thread Martin Sebor
On 12/2/19 9:35 PM, Jonathan Wakely wrote: PR driver/92757 * doc/invoke.texi (Warning Options): Add caveat about some warnings depending on optimization settings. The bug reporter wants this clarified. I'm not entirely convinced it's necessary, but it doesn't seem to do any harm.

[PATCH] adjust object size computation for union accesses and PHIs (PR 92765)

2020-01-15 Thread Martin Sebor
The strcmp optimization newly introduced in GCC 10 relies on the size of the smallest referenced array object to determine whether the function can return zero. When the size of the object is smaller than the length of the other string argument the optimization folds the equality to false. The b

[committed] avoid target dependencies in a couple of tests (PR 92829)

2020-01-20 Thread Martin Sebor
ts to avoid this problem. Mainly for the record, I've also raised bug 93332 for the inaccurate range info that's behind the test failures. Martin commit 414231ba78973dfcb11648a0a5287b989e0148bb Author: Martin Sebor Date: Mon Jan 20 14:53:33 2020 +0100 PR testsuite/92829 - sev

Re: [PATCH] doc: clarify the situation with pointer arithmetic

2020-01-22 Thread Martin Sebor
On 1/22/20 8:32 AM, Richard Biener wrote: On Tue, 21 Jan 2020, Alexander Monakov wrote: On Tue, 21 Jan 2020, Richard Biener wrote: Fourth. That PNVI (I assume it's the whole pointer-provenance stuff) wants to get the "best" of both which can never be done since a compiler needs to have a way

[PATCH] avoid -Wrestrict on sprintf %p with destination as argument (PR 84919)

2020-01-22 Thread Martin Sebor
The early front-end only implementation of -Wrestrict that's still present in GCC 10 issues a false postive for %p arguments that are the same as the destination. Bug 84919 reports an instance of this false positive in the Linux kernel. That attached patch suppresses the front-end warning for th

Re: [PATCH] avoid -Wrestrict on sprintf %p with destination as argument (PR 84919)

2020-01-22 Thread Martin Sebor
On 1/22/20 9:35 PM, Jeff Law wrote: On Wed, 2020-01-22 at 15:59 +0100, Martin Sebor wrote: The early front-end only implementation of -Wrestrict that's still present in GCC 10 issues a false postive for %p arguments that are the same as the destination. Bug 84919 reports an instance of

[committed] update gcc-10/changes.html

2020-01-23 Thread Martin Sebor
I pushed the attached diff to the wwwdocs repository. In links to the manuals that I added I pointed to the upcoming release, 10.1.0, even though the new version directory hasn't been created yet. I also updated existing links pointing to the development version of GCC to point to 10.1.0 instead

[committed] add test for PR 93437

2020-01-28 Thread Martin Sebor
Done in r10-6309-g4dd27b527c503aa50909fe1eb7d308266b1e103a. Martin

Re: [committed] analyzer: avoid using in malloc-1.c

2020-01-30 Thread Martin Sebor
On 1/30/20 5:15 PM, David Malcolm wrote: This test assumes that memset and strlen have been marked with __attribute__((nonnull)), which isn't necessarily the case for an arbitrary . I sometimes find it useful to run tests with a cross-compiler. Those that include standard library headers that

Re: [PATCH] adjust object size computation for union accesses and PHIs (PR 92765)

2020-01-31 Thread Martin Sebor
artin [*] With all the issues around MEM_REFs and types this change needs extra scrutiny. I'm still not sure I fully understand what can and what cannot be safely relied on at this level. On 1/15/20 6:18 AM, Martin Sebor wrote: The strcmp optimization newly introduced in GCC 10 relies on the s

[PATCH] avoid issuing -Wrestrict from folder (PR 93519)

2020-02-03 Thread Martin Sebor
PR 93519 reports a false positive -Wrestrict issued for an inlined call to strcpy that carefully guards against self-copying. This is caused by the caller's arguments substituted into the call during inlining and before dead code elimination. The attached patch avoids this by removing -Wrestrict

Re: [PATCH] avoid issuing -Wrestrict from folder (PR 93519)

2020-02-04 Thread Martin Sebor
On 2/4/20 2:34 AM, Richard Biener wrote: On Tue, Feb 4, 2020 at 1:44 AM Martin Sebor wrote: PR 93519 reports a false positive -Wrestrict issued for an inlined call to strcpy that carefully guards against self-copying. This is caused by the caller's arguments substituted into the call d

Re: [PATCH] avoid issuing -Wrestrict from folder (PR 93519)

2020-02-04 Thread Martin Sebor
On 2/4/20 12:15 PM, Richard Biener wrote: On February 4, 2020 5:30:42 PM GMT+01:00, Jeff Law wrote: On Tue, 2020-02-04 at 10:34 +0100, Richard Biener wrote: On Tue, Feb 4, 2020 at 1:44 AM Martin Sebor wrote: PR 93519 reports a false positive -Wrestrict issued for an inlined call to strcpy

Re: [PATCH] avoid issuing -Wrestrict from folder (PR 93519)

2020-02-04 Thread Martin Sebor
On 2/4/20 2:31 PM, Jeff Law wrote: On Tue, 2020-02-04 at 13:08 -0700, Martin Sebor wrote: On 2/4/20 12:15 PM, Richard Biener wrote: On February 4, 2020 5:30:42 PM GMT+01:00, Jeff Law wrote: On Tue, 2020-02-04 at 10:34 +0100, Richard Biener wrote: On Tue, Feb 4, 2020 at 1:44 AM Martin Sebor

[PATCH] document that alias and target must have the same type

2020-02-04 Thread Martin Sebor
GCC diagnoses declarations of function aliases whose type doesn't match that of the target (ditto for attribute weakref). It doesn't yet diagnose such incompatbilities for variable aliases but that's just an oversight that I will try to remember to correct in GCC 11. The attached patch updates th

Re: [PATCH] avoid issuing -Wrestrict from folder (PR 93519)

2020-02-05 Thread Martin Sebor
On 2/5/20 1:19 AM, Richard Biener wrote: On Tue, Feb 4, 2020 at 11:02 PM Martin Sebor wrote: On 2/4/20 2:31 PM, Jeff Law wrote: On Tue, 2020-02-04 at 13:08 -0700, Martin Sebor wrote: On 2/4/20 12:15 PM, Richard Biener wrote: On February 4, 2020 5:30:42 PM GMT+01:00, Jeff Law wrote: On

Re: [PATCH] document that alias and target must have the same type

2020-02-05 Thread Martin Sebor
On 2/4/20 6:05 PM, Martin Sebor wrote: GCC diagnoses declarations of function aliases whose type doesn't match that of the target (ditto for attribute weakref).  It doesn't yet diagnose such incompatbilities for variable aliases but that's just an oversight that I will try to reme

Re: [PATCH] adjust object size computation for union accesses and PHIs (PR 92765)

2020-02-05 Thread Martin Sebor
On 2/3/20 11:44 AM, Jeff Law wrote: On Fri, 2020-01-31 at 12:04 -0700, Martin Sebor wrote: Attached is a reworked patch since the first one didn't go far enough to solve the major problems. The new solution relies on get_range_strlen_dynamic the same way as the sprintf optimization, and

Re: [PATCH] adjust object size computation for union accesses and PHIs (PR 92765)

2020-02-05 Thread Martin Sebor
On 2/4/20 7:35 AM, Richard Biener wrote: ... Jakub/Richi, comments on this hunk? + tree ref = TREE_OPERAND (TREE_OPERAND (arg, 0), 0); + tree off = TREE_OPERAND (arg, 1); + if ((TREE_CODE (ref) == PARM_DECL || VAR_P (ref)) + && (!DECL_EXTERNAL (ref) +

[committed] avoid pedantic warning in C++ 98 mode: comma at end of enumerator list

2020-02-05 Thread Martin Sebor
I removed the trailing comma and (after a few false starts) managed to push the change in commit r10-6466-g297aa668293d55ffe100d810e92fbe592f262557. I got the error below for my first few attempts. The message had the expected format so I wasn't sure what the problem was until I removed the "[

Re: [PATCH] middle-end/93519 - avoid folding stmts in obviously unreachable code

2020-02-06 Thread Martin Sebor
On 2/6/20 7:52 AM, Richard Biener wrote: The inliner folds stmts delayed, the following arranges things so to not fold stmts that are obviously not reachable to avoid warnings from those code regions. Bootstrapped and tested on x86_64-unknown-linux-gnu. It fixes the reported problem so it work

Re: [PATCH] avoid issuing -Wrestrict from folder (PR 93519)

2020-02-06 Thread Martin Sebor
On 2/6/20 6:16 AM, Richard Biener wrote: On Thu, Feb 6, 2020 at 2:00 PM Jeff Law wrote: On Wed, 2020-02-05 at 09:19 +0100, Richard Biener wrote: On Tue, Feb 4, 2020 at 11:02 PM Martin Sebor wrote: On 2/4/20 2:31 PM, Jeff Law wrote: On Tue, 2020-02-04 at 13:08 -0700, Martin Sebor wrote

[PATCH] fix off-by-one mistakes in attribute access syntax checking (PR 93640)

2020-02-10 Thread Martin Sebor
PR 93641 points out a number of off-by-one mistakes in calls to strncmp in GCC where the bound is (unintentionally) less than the length of the string literal argument. PR 93640 is a separate report of another such mistake in the code that validates the mode argument in attribute access. As a re

[PATCH] issue -Wstringop-overflow for potential overflow, not -truncation (PR 93646)

2020-02-10 Thread Martin Sebor
The reporter of RHBZ #1798636 was mislead and confused by GCC issuing -Wstringop-truncation for a possible overflow in strncat. It took a few iterations to appreciate this subtlety and realize the warning was of the wrong kind. The attached patch adjusts the logic of the function responsible for

[PATCH] avoid user-constructible types in reshape_init_array (PR 90938)

2020-02-11 Thread Martin Sebor
r270155, committed in GCC 9, introduced a transformation that strips redundant trailing zero initializers from array initializer lists in order to support string literals as template arguments. The transformation neglected to consider the case of array elements of trivial class types with user-de

[PATCH] avoid assuming calloc return value is used (PR 93683)

2020-02-11 Thread Martin Sebor
Along with some special handling of calloc calls, r272717 introduced the assumption into stmt_kills_ref_p that the value returned from the call is used. The code triggers an ICE when invoked during DCE in an attempt to determine whether a calloc call can be eliminated. To avoid the ICE the attac

Re: [PATCH] avoid user-constructible types in reshape_init_array (PR 90938)

2020-02-11 Thread Martin Sebor
On 2/11/20 5:01 PM, Marek Polacek wrote: On Tue, Feb 11, 2020 at 01:00:05PM -0700, Martin Sebor wrote: r270155, committed in GCC 9, introduced a transformation that strips redundant trailing zero initializers from array initializer lists in order to support string literals as template arguments

Re: [PATCH] avoid user-constructible types in reshape_init_array (PR 90938)

2020-02-12 Thread Martin Sebor
On 2/11/20 5:28 PM, Jason Merrill wrote: On 2/11/20 9:00 PM, Martin Sebor wrote: r270155, committed in GCC 9, introduced a transformation that strips redundant trailing zero initializers from array initializer lists in order to support string literals as template arguments. The transformation

[PING PATCH] document that alias and target must have the same type

2020-02-12 Thread Martin Sebor
Ping: https://gcc.gnu.org/ml/gcc-patches/2020-02/msg00290.html On 2/5/20 1:13 PM, Martin Sebor wrote: On 2/4/20 6:05 PM, Martin Sebor wrote: GCC diagnoses declarations of function aliases whose type doesn't match that of the target (ditto for attribute weakref).  It doesn't yet dia

Re: Patch ping

2020-02-13 Thread Martin Sebor
On 2/13/20 2:54 AM, Jakub Jelinek wrote: On Wed, Feb 12, 2020 at 02:39:05PM -0700, Jeff Law wrote: On Mon, 2020-02-10 at 10:24 +0100, Jakub Jelinek wrote: Hi! I'd like to ping a couple of patches: PR target/91913 - arm movsi + cmpsi -> movsi_compare0 peephole2 ICE fix https://gcc.gnu.org/

Re: [PATCH] testsuite/strlenopt-81.c: Add target limitation.

2020-02-14 Thread Martin Sebor
On 2/13/20 8:34 PM, Kito Cheng wrote: - strlenopt-81.c has same limitation as strlenopt-80.c, this optimization only work when memcpy expand into load/store. Unlike strlenopt-80.c which is a compile-time test that verifies that the optimization successfully folds the strlen expressions, s

Re: [PATCH] document that alias and target must have the same type

2020-02-14 Thread Martin Sebor
On 2/13/20 3:55 PM, Sandra Loosemore wrote: On 2/5/20 1:13 PM, Martin Sebor wrote: diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index ec99c38a607..3634ce1c423 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -2557,8 +2557,11 @@ __attribute__ ((access (write_only, 1, 2

Re: [PATCH] avoid user-constructible types in reshape_init_array (PR 90938)

2020-02-14 Thread Martin Sebor
On 2/13/20 3:59 PM, Jason Merrill wrote: On 2/12/20 9:21 PM, Martin Sebor wrote: On 2/11/20 5:28 PM, Jason Merrill wrote: On 2/11/20 9:00 PM, Martin Sebor wrote: r270155, committed in GCC 9, introduced a transformation that strips redundant trailing zero initializers from array initializer

[PATCH] drop weakref attribute on function definitions (PR 92799)

2020-02-14 Thread Martin Sebor
Because attribute weakref introduces a kind of a definition, it can only be applied to declarations of symbols that are not defined. GCC normally issues a warning when the attribute is applied to a defined symbol, but PR 92799 shows that it misses some cases on which it then leads to an ICE. The

Re: [PATCH 05/49] vec.h: add auto_delete_vec

2019-12-04 Thread Martin Sebor
On 11/15/19 6:22 PM, David Malcolm wrote: This patch adds a class auto_delete_vec, a subclass of auto_vec that deletes all of its elements on destruction; it's used in many places later in the kit. This is a crude way for a vec to "own" the objects it points to and clean up automatically (essen

Re: [PATCH 06/49] timevar.h: add auto_client_timevar class

2019-12-04 Thread Martin Sebor
On 11/15/19 6:22 PM, David Malcolm wrote: This patch adds a class "auto_client_timevar", similar to auto_timevar, but for plugins to use on their own timing items that aren't in timevar.def gcc/ChangeLog: * timevar.h (class auto_client_timevar): New class. --- gcc/timevar.h | 33 ++

Re: [PATCH 04/49] sbitmap.h: add operator const sbitmap & to auto_sbitmap

2019-12-04 Thread Martin Sebor
On 11/15/19 6:22 PM, David Malcolm wrote: gcc/ChangeLog: * sbitmap.h (auto_sbitmap): Add operator const sbitmap &. --- gcc/sbitmap.h | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/sbitmap.h b/gcc/sbitmap.h index a33175d..3c5b0a4 100644 --- a/gcc/sbitmap.h +++ b/gcc/sbitmap.h @

Re: [PATCH 09/49] gimple const-correctness fixes

2019-12-04 Thread Martin Sebor
On 11/15/19 6:22 PM, David Malcolm wrote: This patch converts various "gimple *" to "const gimple *" and similar fixes for gimple subclasses, adding is_a_helper for gimple subclasses to support the const form of as_a, and adding a few "const" overloads of accessors. This is enough to make pp_gim

Re: [PATCH 10/49] Add -fdiagnostics-nn-line-numbers

2019-12-04 Thread Martin Sebor
On 11/15/19 6:22 PM, David Malcolm wrote: This patch implements -fdiagnostics-nn-line-numbers, a new option which makes diagnostic_show_locus print "NN" rather than specific line numbers when printing the left margin. This is intended purely to make it easier to write certain kinds of DejaGnu te

Re: [PATCH 10/49] Add -fdiagnostics-nn-line-numbers

2019-12-04 Thread Martin Sebor
On 11/15/19 6:22 PM, David Malcolm wrote: This patch implements -fdiagnostics-nn-line-numbers, a new option which makes diagnostic_show_locus print "NN" rather than specific line numbers when printing the left margin. This is intended purely to make it easier to write certain kinds of DejaGnu te

Re: [PATCH 11/49] Add diagnostic_metadata and CWE support

2019-12-04 Thread Martin Sebor
On 11/15/19 6:22 PM, David Malcolm wrote: This patch adds support for associating a diagnostic with an optional diagnostic_metadata object, so that plugins can add extra data to their diagnostics (e.g. mapping a diagnostic to a taxonomy or coding standard such as from CERT or MISRA). Currently t

Re: [PATCH 15/49] Add ordered_hash_map

2019-12-04 Thread Martin Sebor
On 11/15/19 6:23 PM, David Malcolm wrote: This patch adds an ordered_hash_map template, which is similar to hash_map, but preserves insertion order. gcc/ChangeLog: * Makefile.in (OBJS): Add ordered-hash-map-tests.o. * ordered-hash-map-tests.cc: New file. * ordered-hash-ma

Re: [PATCH 20/49] analyzer: new builtins

2019-12-04 Thread Martin Sebor
On 11/15/19 6:23 PM, David Malcolm wrote: gcc/ChangeLog: * builtins.def (BUILT_IN_ANALYZER_BREAK): New builtin. (BUILT_IN_ANALYZER_DUMP): New builtin. (BUILT_IN_ANALYZER_DUMP_EXPLODED_NODES): New builtin. (BUILT_IN_ANALYZER_DUMP_NUM_HEAP_REGIONS): New builtin.

Re: [PATCH 21/49] analyzer: command-line options

2019-12-04 Thread Martin Sebor
On 11/15/19 6:23 PM, David Malcolm wrote: This patch contains the command-line options for the analyzer. Some of the -Wanalyzer- options sounds like they control similar warnings as existing options (e.g., -Wanalyzer-null-argument sounds like -Wnonnull and -Wanalyzer-null-dereference like -Wnu

Re: [PATCH 23/49] analyzer: logging support

2019-12-04 Thread Martin Sebor
On 11/15/19 6:23 PM, David Malcolm wrote: This patch adds a logging framework to the analyzer which handles hierarchical messages (showing the nested structure of the calls). This code is largely based on that in the "jit" subdirectory (with a few changes). An alternative would be to generalize

Re: [PATCH 00/49] RFC: Add a static analysis framework to GCC

2019-12-04 Thread Martin Sebor
On 11/15/19 6:22 PM, David Malcolm wrote: This patch kit introduces a static analysis pass for GCC that can diagnose various kinds of problems in C code at compile-time (e.g. double-free, use-after-free, etc). I haven't looked at the analyzer bits in any detail yet so I have just some very high

Re: [PATCH] extend -Wstringop-overflow to allocated objects (PR 91582)

2019-12-04 Thread Martin Sebor
On 12/2/19 10:06 AM, Jeff Law wrote: On 11/8/19 3:11 PM, Martin Sebor wrote: Unless it's used with _FORTIFY_SOURCE, -Wstringop-overflow doesn't consider out-of-bounds accesses to objects allocated by alloca, malloc, other functions declared with attribute alloc_size, or even VLAs wit

Re: [PATCH] Come up with constructors of symtab_node, cgraph_node and varpool_node.

2019-12-05 Thread Martin Sebor
On 12/5/19 8:13 AM, Martin Liška wrote: On 12/5/19 2:03 PM, Jan Hubicka wrote: Hi. As mentioned in the PR, there are classes in cgraph.h that are not PODs and are initialized with ggc_alloc_cleared. So that I'm suggesting to use proper constructors. I added ggc_new function that can be used a

Re: [RFC] Characters per line: from punch card (80) to line printer (132)

2019-12-05 Thread Martin Sebor
On 12/5/19 8:46 AM, Thomas Schwinge wrote: Hi! ;-P Jakub, thanks for furnishing me a fit occasion here: On 2019-12-05T16:15:15+0100, Jakub Jelinek wrote: [...] much more indented though, but you could use a temporary, like: tree nullarg = null_pointer_node; I object to

[PATCH] avoid using uninitialized offset (PR 92622)

2019-12-05 Thread Martin Sebor
I've isolated the intermittent failures of a test for a recent enhancement to -Warray-bounds reported in PR 92622 to the use of an offset left uninitialized by a failed call to get_addr_base_and_unit_offset. The attached patch makes sure the variable is only used if the call succeeds. I will com

Re: [PATCH] add -Wmismatched-tags (PR 61339)

2019-12-05 Thread Martin Sebor
On 12/4/19 4:37 PM, Jason Merrill wrote: On 12/3/19 4:49 PM, Martin Sebor wrote: On 8/5/19 4:30 PM, Jason Merrill wrote: On Mon, Aug 5, 2019 at 5:50 PM Martin Sebor wrote: On 8/5/19 1:25 PM, Jason Merrill wrote: On 8/1/19 7:35 PM, Martin Sebor wrote: On 8/1/19 12:09 PM, Jason Merrill

Re: [PATCH] include size and offset in -Wstringop-overflow

2019-12-05 Thread Martin Sebor
If yes, since I don't think I have the time for it for GCC 10 I need to decide whether to drop just this improvement or all of the buffer overflow checks that depend on it. Let me know which you prefer. As I mentioned in my previous message, I think we've got two potential paths.  We could just

Re: [PATCH] extend -Wstringop-overflow to allocated objects (PR 91582)

2019-12-06 Thread Martin Sebor
On 12/6/19 8:44 AM, Christophe Lyon wrote: On Thu, 5 Dec 2019 at 02:37, Martin Sebor wrote: On 12/2/19 10:06 AM, Jeff Law wrote: On 11/8/19 3:11 PM, Martin Sebor wrote: Unless it's used with _FORTIFY_SOURCE, -Wstringop-overflow doesn't consider out-of-bounds accesses to objects al

Re: [PATCH] track dynamic allocation in strlen (PR 91582)

2019-12-06 Thread Martin Sebor
On 11/30/19 9:31 AM, Christophe Lyon wrote: On Tue, 12 Nov 2019 at 02:28, Martin Sebor wrote: The attached patch extends the strlen pass to detect out-of-bounds accesses to memory allocated by calls to other allocation functions besides calloc and malloc, as well as VLAs, and user-defined

[PING 3][PATCH] track dynamic allocation in strlen (PR 91582)

2019-12-06 Thread Martin Sebor
.html [2] extend -Wstringop-overflow to allocated objects (committed in r278983) https://gcc.gnu.org/ml/gcc-patches/2019-12/msg00263.html On 11/25/19 10:54 AM, Martin Sebor wrote: Ping: https://gcc.gnu.org/ml/gcc-patches/2019-11/msg00812.html On 11/18/19 11:23 AM, Martin Sebor wrote:

Re: [PATCH] bring -Warray-bounds closer to -Wstringop-overflow (PR91647, 91463, 91679)

2019-12-09 Thread Martin Sebor
On 12/9/19 9:11 AM, Matthew Malcomson wrote: On 01/11/2019 21:09, Martin Sebor wrote: diff --git a/gcc/gimple-match-head.c b/gcc/gimple-match-head.c index 53278168a59..d7c74a1865a 100644 --- a/gcc/gimple-match-head.c +++ b/gcc/gimple-match-head.c @@ -837,8 +837,8

Re: [PATCH] add -Wmismatched-tags (PR 61339)

2019-12-09 Thread Martin Sebor
On 12/6/19 12:08 PM, Jason Merrill wrote: On 12/5/19 6:47 PM, Jakub Jelinek wrote: On Thu, Dec 05, 2019 at 04:33:10PM -0700, Martin Sebor wrote: It's hard to distinguish between this type and the previous one by name; this one should probably have "map" in its name

Re: [PATCH 26/49] analyzer: new files: digraph.{cc|h} and shortest-paths.h

2019-12-09 Thread Martin Sebor
On 11/15/19 6:23 PM, David Malcolm wrote: This patch adds template classes for directed graphs, their nodes and edges, and for finding the shortest path through such a graph. Just a few mostly minor comments from me, in a similar vein as on some of the other patches. gcc/ChangeLog: *

Re: [PATCH 29/49] analyzer: new files: tristate.{cc|h}

2019-12-09 Thread Martin Sebor
On 11/15/19 6:23 PM, David Malcolm wrote: gcc/ChangeLog: * analyzer/tristate.cc: New file. * analyzer/tristate.h: New file. --- gcc/analyzer/tristate.cc | 222 +++ gcc/analyzer/tristate.h | 82 + 2 files changed, 30

Re: [PATCH 28/49] analyzer: new files: analyzer.{cc|h}

2019-12-10 Thread Martin Sebor
On 11/15/19 6:23 PM, David Malcolm wrote: gcc/ChangeLog: * analyzer/analyzer.cc: New file. * analyzer/analyzer.h: New file. Here are a few more comments/suggestions as I'm slowly making my way through the patch, partly for my own benefit. Hopefully they're at least moderately u

Re: [PATCH] avoid invoking assignment on uninitialized objects (PR 92761, 92762)

2019-12-10 Thread Martin Sebor
On 12/10/19 3:07 PM, David Malcolm wrote: On Tue, 2019-12-03 at 15:41 -0700, Martin Sebor wrote: After allocating a new chunk of memory hash_table::expand() copy- assigns elements from the current array over the newly allocated elements without constructing them. Similarly, after destroying

Re: [PATCH] include size and offset in -Wstringop-overflow

2019-12-11 Thread Martin Sebor
On 12/5/19 4:37 PM, Martin Sebor wrote: If yes, since I don't think I have the time for it for GCC 10 I need to decide whether to drop just this improvement or all of the buffer overflow checks that depend on it. Let me know which you prefer. As I mentioned in my previous message, I

Re: [PING 3][PATCH] track dynamic allocation in strlen (PR 91582)

2019-12-11 Thread Martin Sebor
. On 12/6/19 5:19 PM, Martin Sebor wrote: With part 2 (below) of this work committed, I've rebased the patch on the top of trunk and on top of the updated part 1 (also below). Attached is the result, retested on x86_64-linux. [1] include size and offset in -Wstringop-overflow     https://g

Re: [PATCH 11/49] Add diagnostic_metadata and CWE support

2019-12-13 Thread Martin Sebor
On 12/12/19 7:59 PM, David Malcolm wrote: On Wed, 2019-12-04 at 10:36 -0700, Martin Sebor wrote: On 11/15/19 6:22 PM, David Malcolm wrote: This patch adds support for associating a diagnostic with an optional diagnostic_metadata object, so that plugins can add extra data to their diagnostics

Re: [PING 3][PATCH] track dynamic allocation in strlen (PR 91582)

2019-12-13 Thread Martin Sebor
After more testing by Jeff's buildbot and correcting the problems it exposed I have committed the attached patch in r279392. Martin On 12/11/19 4:23 PM, Martin Sebor wrote: Jeff's buildbot exposed a bug in the patch that caused false positives in cases involving negative of

[committed] fix typos in attribute access

2019-12-14 Thread Martin Sebor
Committed in r279398. Martin gcc/ChangeLog: * doc/extend.texi (attribute access): Correct typos. Index: gcc/doc/extend.texi === --- gcc/doc/extend.texi (revision 279397) +++ gcc/doc/extend.texi (working copy) @@ -2489,10 +2489,10

Re: [PATCH] add -Wmismatched-tags (PR 61339)

2019-12-16 Thread Martin Sebor
29 PM, Martin Sebor wrote: On 12/6/19 12:08 PM, Jason Merrill wrote: On 12/5/19 6:47 PM, Jakub Jelinek wrote: On Thu, Dec 05, 2019 at 04:33:10PM -0700, Martin Sebor wrote: It's hard to distinguish between this type and the previous one by name; this one should probably have "map" in

[committed] avoid assuming array indices are zero-based (PR 92952)

2019-12-16 Thread Martin Sebor
The gfortran.dg/lto/pr87689 test fails as a result of a -Wstringop-overflow warning. The warning is only enabled for the C family of languages and LTO but it looks like LTO obviates this distinction. Last week's enhancement to compute_objsize seems like the most likely culprit, although the root

Re: [PATCH] add -Wmismatched-tags (PR 61339)

2019-12-16 Thread Martin Sebor
On 12/16/19 3:51 PM, Jason Merrill wrote: On 12/9/19 7:29 PM, Martin Sebor wrote: Just a few nits: +/* A mapping between a TYPE_DECL for a class and the class_decl_loc_t +   description above.  */ +typedef hash_map class_to_loc_map_t; +static class_to_loc_map_t class2loc; I think we can

Re: [committed] avoid assuming array indices are zero-based (PR 92952)

2019-12-16 Thread Martin Sebor
On 12/16/19 3:44 PM, Jakub Jelinek wrote: On Mon, Dec 16, 2019 at 03:28:29PM -0700, Martin Sebor wrote: PR middle-end/92952 - gfortran.dg/lto/pr87689 FAILs gcc/ChangeLog: PR middle-end/92952 * builtins.c (compute_objsize): Adjust offset by the array low bound. Index: gcc

Re: [PATCH] Some compute_objsize/gimple_call_alloc_size/maybe_warn_overflow cleanups (PR tree-optimization/92868)

2019-12-17 Thread Martin Sebor
On 12/17/19 1:58 AM, Jakub Jelinek wrote: Hi! When looking at the PR, I wrote a cleanup patch with various things I've noticed, with latest Martin's changes half of them aren't valid anymore, but I found further ones. So, besides formatting fixes, this patch tries to make sure the rng1 ranges ar

Re: [PATCH] Document cloning for the target_clone attribute.

2020-01-06 Thread Martin Sebor
On 1/6/20 3:05 AM, Martin Liška wrote: Hi. The patch is about explanation what happens when a target_clone function calls a function without the attribute. Ready for trunk? Thanks, Martin gcc/ChangeLog: 2020-01-06  Martin Liska  PR ipa/83411 * doc/extend.texi: Explain cloning for

Re: [PATCH] Some compute_objsize/gimple_call_alloc_size/maybe_warn_overflow cleanups (PR tree-optimization/92868)

2020-01-07 Thread Martin Sebor
On 12/18/19 1:49 AM, Jakub Jelinek wrote: On Tue, Dec 17, 2019 at 09:53:43AM -0700, Martin Sebor wrote: I appreciate a cleanup but I don't have the impression this patch does clean anything up. Because of all the formatting changes and no tests the effect of the changes isn't as c

<    1   2   3   4   5   6   7   8   9   10   >