public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/50584] New: No warning for passing small array to C99 static array declarator
@ 2011-09-30 18:15 ian at airs dot com
  2013-02-19  6:51 ` [Bug c/50584] " andi-gcc at firstfloor dot org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: ian at airs dot com @ 2011-09-30 18:15 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

             Bug #: 50584
           Summary: No warning for passing small array to C99 static array
                    declarator
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ian@airs.com


C99 introduced the idea of using static in an array declarator in a function
prototype parameter.  My reading of the standard is that using static means
that the actual argument must be at least that size.  GCC should at least issue
a warning when that requirement is clearly violated.

For example, this program


extern void bar (void *a[static 6]);
void foo() {
  void *a1;
  void *a2[5];
  void *a3[6];
  void *a4[10];

  bar (&a1);
  bar (a2);
  bar (a3);
  bar (a4);
}

should issue a warning, or perhaps even an error, for the first two calls to
bar, as the compiler can clearly see that the values are not large enough.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c/50584] No warning for passing small array to C99 static array declarator
  2011-09-30 18:15 [Bug c/50584] New: No warning for passing small array to C99 static array declarator ian at airs dot com
@ 2013-02-19  6:51 ` andi-gcc at firstfloor dot org
  2013-08-14  4:46 ` me at minglis dot id.au
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: andi-gcc at firstfloor dot org @ 2013-02-19  6:51 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

Andi Kleen <andi-gcc at firstfloor dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andi-gcc at firstfloor dot
                   |                            |org

--- Comment #1 from Andi Kleen <andi-gcc at firstfloor dot org> 2013-02-19 06:51:18 UTC ---
Confirmed. Still happens with 4.7/4.8


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c/50584] No warning for passing small array to C99 static array declarator
  2011-09-30 18:15 [Bug c/50584] New: No warning for passing small array to C99 static array declarator ian at airs dot com
  2013-02-19  6:51 ` [Bug c/50584] " andi-gcc at firstfloor dot org
@ 2013-08-14  4:46 ` me at minglis dot id.au
  2013-08-21 22:34 ` joseph at codesourcery dot com
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: me at minglis dot id.au @ 2013-08-14  4:46 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

Malcolm Inglis <me at minglis dot id.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |me at minglis dot id.au

--- Comment #2 from Malcolm Inglis <me at minglis dot id.au> ---
GCC 4.8.1 is still failing to warn for static array indices in function
parameters.

The C99 status pages say this feature has been done since 3.1:
http://gcc.gnu.org/gcc-3.1/c99status.html

Was there a regression?


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c/50584] No warning for passing small array to C99 static array declarator
  2011-09-30 18:15 [Bug c/50584] New: No warning for passing small array to C99 static array declarator ian at airs dot com
  2013-02-19  6:51 ` [Bug c/50584] " andi-gcc at firstfloor dot org
  2013-08-14  4:46 ` me at minglis dot id.au
@ 2013-08-21 22:34 ` joseph at codesourcery dot com
  2013-09-25 10:21 ` me at minglis dot id.au
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: joseph at codesourcery dot com @ 2013-08-21 22:34 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

--- Comment #3 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
The point of this language feature is for optimization, not diagnostics - 
but there is no requirement for either; GCC does all the checks required 
by C99 on the contexts in which [static] may be used.  c99status.html 
specifically notes that it is not used for optimization.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c/50584] No warning for passing small array to C99 static array declarator
  2011-09-30 18:15 [Bug c/50584] New: No warning for passing small array to C99 static array declarator ian at airs dot com
                   ` (2 preceding siblings ...)
  2013-08-21 22:34 ` joseph at codesourcery dot com
@ 2013-09-25 10:21 ` me at minglis dot id.au
  2014-04-10 12:28 ` jimis at gmx dot net
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: me at minglis dot id.au @ 2013-09-25 10:21 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

--- Comment #4 from Malcolm Inglis <me at minglis dot id.au> ---
I don't have a copy of the C99 standard, but IBM says [1] that if the function
is called with a pointer to a smaller array than specified with `static`, then
the behavior is undefined. Ergo, there should be a warning.

Could someone change the status of this bug?

I'm about 60% sure that I once played around with this in GCC, and it correctly
reported an error. This wouldn't have been too long ago; maybe 4.6 or even 4.7.

Clang emits a warning for this. [2]

I think this is a fantastic language feature. It's a shame GCC doesn't support
it yet.

[1]:
http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/topic/com.ibm.xlcpp8a.doc/language/ref/param_decl.htm

[2]: http://hamberg.no/erlend/posts/2013-02-18-static-array-indices.html


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c/50584] No warning for passing small array to C99 static array declarator
  2011-09-30 18:15 [Bug c/50584] New: No warning for passing small array to C99 static array declarator ian at airs dot com
                   ` (3 preceding siblings ...)
  2013-09-25 10:21 ` me at minglis dot id.au
@ 2014-04-10 12:28 ` jimis at gmx dot net
  2014-04-10 12:51 ` mpolacek at gcc dot gnu.org
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: jimis at gmx dot net @ 2014-04-10 12:28 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

jimis <jimis at gmx dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jimis at gmx dot net

--- Comment #5 from jimis <jimis at gmx dot net> ---
I'm currently using this C99 feature. A warning would be nice if NULL or small
arrays are passed.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c/50584] No warning for passing small array to C99 static array declarator
  2011-09-30 18:15 [Bug c/50584] New: No warning for passing small array to C99 static array declarator ian at airs dot com
                   ` (4 preceding siblings ...)
  2014-04-10 12:28 ` jimis at gmx dot net
@ 2014-04-10 12:51 ` mpolacek at gcc dot gnu.org
  2015-07-03  1:20 ` sergei.ivn+bugzilla at gmail dot com
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-04-10 12:51 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I don't recommend this kind of usage of the static keyword.  There was even the
possibility of removing/deprecating this feature.  Quoting from DR#205:
"There was a unanimous vote that the feature is ugly, and a good consensus that
its incorporation into the standard at the 11th hour was an unfortunate
decision."


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c/50584] No warning for passing small array to C99 static array declarator
  2011-09-30 18:15 [Bug c/50584] New: No warning for passing small array to C99 static array declarator ian at airs dot com
                   ` (5 preceding siblings ...)
  2014-04-10 12:51 ` mpolacek at gcc dot gnu.org
@ 2015-07-03  1:20 ` sergei.ivn+bugzilla at gmail dot com
  2015-07-03  1:41 ` sergei.ivn+bugzilla at gmail dot com
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: sergei.ivn+bugzilla at gmail dot com @ 2015-07-03  1:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

Serg Iv <sergei.ivn+bugzilla at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sergei.ivn+bugzilla at gmail dot c
                   |                            |om

--- Comment #7 from Serg Iv <sergei.ivn+bugzilla at gmail dot com> ---
Some excerpts from the C11 standard:

/-----
If the keyword static also appears within the [ and ] of the array type
derivation, then for each call to the function, the value of the corresponding
actual argument shall provide access to the first element of an array with at
least as many elements as specified by the size expression.
\-----

And another one:

/-----
The following are all compatible function prototype declarators:
[..snip..]
void f(double a[restrict 3][5]);
void f(double a[restrict static 3][5]);

(Note that the last declaration also specifies that the argument corresponding
to a in any call to f must be a non-null pointer to the first of at least three
arrays of 5 doubles, which the others do not.)
\-----

I'm not sure about warnings (the meaning of the word "shall" is unclear for
me), but IMO according to the standard null-pointers should issue an *error*.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c/50584] No warning for passing small array to C99 static array declarator
  2011-09-30 18:15 [Bug c/50584] New: No warning for passing small array to C99 static array declarator ian at airs dot com
                   ` (6 preceding siblings ...)
  2015-07-03  1:20 ` sergei.ivn+bugzilla at gmail dot com
@ 2015-07-03  1:41 ` sergei.ivn+bugzilla at gmail dot com
  2015-07-03  9:34 ` manu at gcc dot gnu.org
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: sergei.ivn+bugzilla at gmail dot com @ 2015-07-03  1:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

--- Comment #8 from Serg Iv <sergei.ivn+bugzilla at gmail dot com> ---
Forgot to say that C99 standard has the same sentences.

Useful links:

C99 draft http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf

C11 draft http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1570.pdf


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c/50584] No warning for passing small array to C99 static array declarator
  2011-09-30 18:15 [Bug c/50584] New: No warning for passing small array to C99 static array declarator ian at airs dot com
                   ` (7 preceding siblings ...)
  2015-07-03  1:41 ` sergei.ivn+bugzilla at gmail dot com
@ 2015-07-03  9:34 ` manu at gcc dot gnu.org
  2015-07-03 12:50 ` sergei.ivn+bugzilla at gmail dot com
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: manu at gcc dot gnu.org @ 2015-07-03  9:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-07-03
                 CC|                            |manu at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #9 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Malcolm Inglis from comment #4)
> Could someone change the status of this bug?

Notwithstanding whether the feature is pretty or ugly, GCC does accept this
code and warnings for undefined behavior, when possible, are desired. Thus,
confirmed. 

This does not mean anyone is going to work on fixing this. Please, if you are
using this feature and would like to see this warning in GCC, please consider
contributing it:
https://gcc.gnu.org/wiki/GettingStarted#Basics:_Contributing_to_GCC_in_10_easy_steps

If you start working on this, it would be good to say so here.
>From gcc-bugs-return-491346-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Jul 03 09:35:56 2015
Return-Path: <gcc-bugs-return-491346-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 124587 invoked by alias); 3 Jul 2015 09:35:56 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 124524 invoked by uid 48); 3 Jul 2015 09:35:52 -0000
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/66665] Increment instruction is not propagated into address operand
Date: Fri, 03 Jul 2015 09:35:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: rtl-optimization
X-Bugzilla-Version: 6.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: ubizjak at gmail dot com
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Resolution: DUPLICATE
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 6.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status resolution
Message-ID: <bug-66665-4-DcVmWuDPiS@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66665-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66665-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-07/txt/msg00236.txt.bz2
Content-length: 493

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66665

Uroš Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #3 from Uroš Bizjak <ubizjak at gmail dot com> ---
Dup.

*** This bug has been marked as a duplicate of bug 66749 ***
>From gcc-bugs-return-491347-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Jul 03 09:35:57 2015
Return-Path: <gcc-bugs-return-491347-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 124753 invoked by alias); 3 Jul 2015 09:35:56 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 124553 invoked by uid 48); 3 Jul 2015 09:35:53 -0000
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/66749] [4.9/5/6] gcc.target/i386/addr-sel-1.c fails to merge array index into one instruction with -m32 -mregparm=3 or with -miamcu
Date: Fri, 03 Jul 2015 09:35:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.9.3
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: ubizjak at gmail dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-66749-4-Rx8TunyVfD@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66749-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66749-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-07/txt/msg00237.txt.bz2
Content-length: 447

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66749

Uroš Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kyukhin at gcc dot gnu.org

--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> ---
*** Bug 66665 has been marked as a duplicate of this bug. ***
>From gcc-bugs-return-491348-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Jul 03 09:48:08 2015
Return-Path: <gcc-bugs-return-491348-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 51751 invoked by alias); 3 Jul 2015 09:48:08 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 51679 invoked by uid 48); 3 Jul 2015 09:48:03 -0000
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/66749] [4.9/5/6] gcc.target/i386/addr-sel-1.c fails to merge array index into one instruction with -m32 -mregparm=3 or with -miamcu
Date: Fri, 03 Jul 2015 09:48:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.9.3
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: ubizjak at gmail dot com
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on everconfirmed
Message-ID: <bug-66749-4-ue0zSCMfs8@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66749-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66749-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-07/txt/msg00238.txt.bz2
Content-length: 652

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66749

Uroš Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-07-03
     Ever confirmed|0                           |1

--- Comment #3 from Uroš Bizjak <ubizjak at gmail dot com> ---
This is a tuning issue and depends on cost tables.

I suggest to change the testcase to generic tuning, we won't change cost tables
for older chips just because one test fails.
>From gcc-bugs-return-491349-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Jul 03 09:52:56 2015
Return-Path: <gcc-bugs-return-491349-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 56534 invoked by alias); 3 Jul 2015 09:52:56 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 56496 invoked by uid 55); 3 Jul 2015 09:52:51 -0000
From: "jgreenhalgh at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/66119] [5/6 Regression] in optimization of avx-code
Date: Fri, 03 Jul 2015 09:52:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: 5.1.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jgreenhalgh at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: jgreenhalgh at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.2
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-66119-4-3hfv8fYJ7A@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66119-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66119-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-07/txt/msg00239.txt.bz2
Content-length: 1128

https://gcc.gnu.org/bugzilla/show_bug.cgi?idf119

--- Comment #13 from James Greenhalgh <jgreenhalgh at gcc dot gnu.org> ---
Author: jgreenhalgh
Date: Fri Jul  3 09:52:20 2015
New Revision: 225372

URL: https://gcc.gnu.org/viewcvs?rev"5372&root=gcc&view=rev
Log:
[Backport Patch SRA] Fix PR66119 by calling get_move_ratio in SRA

gcc/

        PR tree-optimization/66119
        * toplev.c (process_options): Don't set up default values for
        the sra_max_scalarization_size_{speed,size} parameters.
        * tree-sra (analyze_all_variable_accesses): If no values
        have been set for the sra_max_scalarization_size_{speed,size}
        parameters, call get_move_ratio to get target defaults.

gcc/testsuite/

        PR tree-optimization/66119
        * g++.dg/opt/pr66119.C: New.


Added:
    branches/gcc-5-branch/gcc/testsuite/g++.dg/opt/pr66119.C
      - copied unchanged from r225369, trunk/gcc/testsuite/g++.dg/opt/pr66119.C
Modified:
    branches/gcc-5-branch/gcc/ChangeLog
    branches/gcc-5-branch/gcc/testsuite/ChangeLog
    branches/gcc-5-branch/gcc/toplev.c
    branches/gcc-5-branch/gcc/tree-sra.c


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c/50584] No warning for passing small array to C99 static array declarator
  2011-09-30 18:15 [Bug c/50584] New: No warning for passing small array to C99 static array declarator ian at airs dot com
                   ` (8 preceding siblings ...)
  2015-07-03  9:34 ` manu at gcc dot gnu.org
@ 2015-07-03 12:50 ` sergei.ivn+bugzilla at gmail dot com
  2020-05-19 20:55 ` msebor at gcc dot gnu.org
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: sergei.ivn+bugzilla at gmail dot com @ 2015-07-03 12:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

--- Comment #10 from Serg Iv <sergei.ivn+bugzilla at gmail dot com> ---
Some thoughts after I read C99 rationale.

Actually, [static N] it's a PROMISE to a compiler, that programmer will always
provide N pieces of data. *ALWAYS*.
Therefore compiler can do with this data whatever it wants. It can, for
instance, copy it (all N elements) somewhere to some local cache for
optimization. Or send it into the space towards the Ape Planet to use brand new
Appe book for calculations.
If the programmer didn't provide N pieces of the information - we may have
segfault, crash, bsod or nuclear war, it depends. It not a compiler's headache,
it's a programmer fault.

So, IMO the right way for GCC is 
a) if it get NULL pointer through all optimization or smaller array is provided
- error in compile time
b) if func's supplied with an array lenght >= N, compile without errors and
warnings
c) otherwise - warning.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c/50584] No warning for passing small array to C99 static array declarator
  2011-09-30 18:15 [Bug c/50584] New: No warning for passing small array to C99 static array declarator ian at airs dot com
                   ` (9 preceding siblings ...)
  2015-07-03 12:50 ` sergei.ivn+bugzilla at gmail dot com
@ 2020-05-19 20:55 ` msebor at gcc dot gnu.org
  2020-07-29  1:25 ` msebor at gcc dot gnu.org
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-05-19 20:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2015-07-03 00:00:00         |2020-5-19
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot gnu.org

--- Comment #15 from Martin Sebor <msebor at gcc dot gnu.org> ---
GCC 10 introduced attribute access to associate a pointer argument with a size
of the object it points to.  Although the GCC 10 implementation of the
attribute cannot express the same relationship for VLA arguments, conceptually,
it should only take a small extension to do it.  I plan to work on it for GCC
11.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c/50584] No warning for passing small array to C99 static array declarator
  2011-09-30 18:15 [Bug c/50584] New: No warning for passing small array to C99 static array declarator ian at airs dot com
                   ` (10 preceding siblings ...)
  2020-05-19 20:55 ` msebor at gcc dot gnu.org
@ 2020-07-29  1:25 ` msebor at gcc dot gnu.org
  2020-09-19 23:57 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-07-29  1:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch

--- Comment #16 from Martin Sebor <msebor at gcc dot gnu.org> ---
Patch: https://gcc.gnu.org/pipermail/gcc-patches/2020-July/550920.html

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c/50584] No warning for passing small array to C99 static array declarator
  2011-09-30 18:15 [Bug c/50584] New: No warning for passing small array to C99 static array declarator ian at airs dot com
                   ` (11 preceding siblings ...)
  2020-07-29  1:25 ` msebor at gcc dot gnu.org
@ 2020-09-19 23:57 ` cvs-commit at gcc dot gnu.org
  2020-09-19 23:57 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-19 23:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

--- Comment #17 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:

https://gcc.gnu.org/g:6450f07388f9fe575a489c9309c36012b17b88b0

commit r11-3303-g6450f07388f9fe575a489c9309c36012b17b88b0
Author: Martin Sebor <msebor@redhat.com>
Date:   Sat Sep 19 17:21:52 2020 -0600

    Infrastructure & C front end changes for array parameter checking (PR
c/50584).

    gcc/ChangeLog:

            PR c/50584
            * attribs.c (decl_attributes): Also pass decl along with type
            attributes to handlers.
            (init_attr_rdwr_indices): Change second argument to attribute
chain.
            Handle internal attribute representation in addition to external.
            (get_parm_access): New function.
            (attr_access::to_internal_string): Define new member function.
            (attr_access::to_external_string): Define new member function.
            (attr_access::vla_bounds): Define new member function.
            * attribs.h (struct attr_access): Declare new members.
            (attr_access::from_mode_char): Define new member function.
            (get_parm_access): Declare new function.
            * calls.c (initialize_argument_information): Pass function type
            attributes to init_attr_rdwr_indices.
            * doc/invoke.texi (-Warray-parameter, -Wvla-parameter): Document.
            * tree-pretty-print.c (dump_generic_node): Correct handling of
            qualifiers.
            * tree-ssa-uninit.c (maybe_warn_pass_by_reference): Same.
            * tree.h (access_mode): Add new enumerator.

    gcc/c-family/ChangeLog:

            PR c/50584
            * c-attribs.c (c_common_attribute_table): Add "arg spec" attribute.
            (handle_argspec_attribute): New function.
            (get_argument, get_argument_type): New functions.
            (append_access_attrs): Add overload.  Handle internal attribute
            representation in addition to external.
            (handle_access_attribute): Handle internal attribute representation
            in addition to external.
            (build_attr_access_from_parms): New function.

    gcc/c-family/ChangeLog:

            PR c/50584
            * c-common.h (warn_parm_array_mismatch): Declare new function.
            (has_attribute): Move declaration of an existing function.
            (build_attr_access_from_parms): Declare new function.
            * c-warn.c (parm_array_as_string): Define new function.
            (plus_one):  Define new function.
            (warn_parm_ptrarray_mismatch): Define new function.
            (warn_parm_array_mismatch):  Define new function.
            (vla_bound_parm_decl): New function.
            * c.opt (-Warray-parameter, -Wvla-parameter): New options.
            * c-pretty-print.c (pp_c_type_qualifier_list): Don't print array
type
            qualifiers here...
            (c_pretty_printer::direct_abstract_declarator): ...but instead
print
            them in brackets here.  Also print [static].  Strip extraneous
            expressions from VLA bounds.

    gcc/c/ChangeLog:

            PR c/50584
            * c-decl.c (lookup_last_decl): Define new function.
            (c_decl_attributes): Call it.
            (start_decl): Add argument and use it.
            (finish_decl): Call build_attr_access_from_parms and
decl_attributes.
            (get_parm_array_spec): Define new function.
            (push_parm_decl): Call get_parm_array_spec.
            (start_function): Call warn_parm_array_mismatch.  Build attribute
            access and add it to current function.
            * c-parser.c (c_parser_declaration_or_fndef): Diagnose mismatches
            in forms of array parameters.
            * c-tree.h (start_decl): Add argument.

    gcc/testsuite/ChangeLog:

            PR c/50584
            * gcc.dg/attr-access-read-write-2.c: Adjust text of expected
message.
            * c-c++-common/Warray-bounds-6.c: Correct C++ declaration, adjust
            text of expected diagnostics.
            * gcc.dg/Wbuiltin-declaration-mismatch-9.c: Prune expected warning.
            * gcc.dg/Warray-parameter-2.c: New test.
            * gcc.dg/Warray-parameter-3.c: New test.
            * gcc.dg/Warray-parameter-4.c: New test.
            * gcc.dg/Warray-parameter-5.c: New test.
            * gcc.dg/Warray-parameter.c: New test.
            * gcc.dg/Wvla-parameter-2.c: New test.
            * gcc.dg/Wvla-parameter-3.c: New test.
            * gcc.dg/Wvla-parameter.c: New test.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c/50584] No warning for passing small array to C99 static array declarator
  2011-09-30 18:15 [Bug c/50584] New: No warning for passing small array to C99 static array declarator ian at airs dot com
                   ` (12 preceding siblings ...)
  2020-09-19 23:57 ` cvs-commit at gcc dot gnu.org
@ 2020-09-19 23:57 ` cvs-commit at gcc dot gnu.org
  2020-09-19 23:57 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-19 23:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

--- Comment #18 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:

https://gcc.gnu.org/g:baad4c48a85a354d2bf1b17e5aff71203c08adea

commit r11-3305-gbaad4c48a85a354d2bf1b17e5aff71203c08adea
Author: Martin Sebor <msebor@redhat.com>
Date:   Sat Sep 19 17:37:05 2020 -0600

    Extend -Wstringop-overflow to detect out-of-bounds accesses to array
parameters.

    gcc/ChangeLog:

            PR c/50584
            * builtins.c (warn_for_access): Add argument.  Distinguish between
            reads and writes.
            (check_access): Add argument.  Distinguish between reads and
writes.
            (gimple_call_alloc_size): Set range even on failure.
            (gimple_parm_array_size): New function.
            (compute_objsize): Call it.
            (check_memop_access): Pass check_access an additional argument.
            (expand_builtin_memchr, expand_builtin_strcat): Same.
            (expand_builtin_strcpy, expand_builtin_stpcpy_1): Same.
            (expand_builtin_stpncpy, check_strncat_sizes): Same.
            (expand_builtin_strncat, expand_builtin_strncpy): Same.
            (expand_builtin_memcmp): Same.
            * builtins.h (compute_objsize): Declare a new overload.
            (gimple_parm_array_size): Declare.
            (check_access): Add argument.
            * calls.c (append_attrname): Simplify.
            (maybe_warn_rdwr_sizes): Handle internal attribute access.
            * tree-ssa-uninit.c (maybe_warn_pass_by_reference): Avoid adding
            quotes.

    gcc/testsuite/ChangeLog:

            PR c/50584
            * c-c++-common/Wsizeof-pointer-memaccess1.c: Disable new expected
            warnings.
            * g++.dg/ext/attr-access.C: Update text of expected warnings.
            * gcc.dg/Wstringop-overflow-23.c: Same.
            * gcc.dg/Wstringop-overflow-24.c: Same.
            * gcc.dg/attr-access-none.c: Same.
            * gcc.dg/dfp/composite-type.c: Prune expected warnings.
            * gcc.dg/torture/pr57147-1.c: Add a member to an otherwise empty
            struct to avoid a warning.
            * gcc.dg/torture/pr57147-3.c: Same.
            * gcc.dg/Warray-bounds-30.c: Adjust.
            * gcc.dg/attr-access-none.c: Same.
            * gcc.dg/Wstringop-overflow-40.c: New test.
            * gcc.dg/attr-access-2.c: New test.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c/50584] No warning for passing small array to C99 static array declarator
  2011-09-30 18:15 [Bug c/50584] New: No warning for passing small array to C99 static array declarator ian at airs dot com
                   ` (13 preceding siblings ...)
  2020-09-19 23:57 ` cvs-commit at gcc dot gnu.org
@ 2020-09-19 23:57 ` cvs-commit at gcc dot gnu.org
  2020-09-20  0:03 ` msebor at gcc dot gnu.org
  2020-09-21 20:55 ` cvs-commit at gcc dot gnu.org
  16 siblings, 0 replies; 18+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-19 23:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

--- Comment #19 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:

https://gcc.gnu.org/g:3f9a497d1b0dd9da87908a11b59bf364ad40ddca

commit r11-3306-g3f9a497d1b0dd9da87908a11b59bf364ad40ddca
Author: Martin Sebor <msebor@redhat.com>
Date:   Sat Sep 19 17:47:29 2020 -0600

    Extend -Warray-bounds to detect out-of-bounds accesses to array parameters.

    gcc/ChangeLog:

            PR middle-end/82608
            PR middle-end/94195
            PR c/50584
            PR middle-end/84051
            * gimple-array-bounds.cc (get_base_decl): New function.
            (get_ref_size): New function.
            (trailing_array): New function.
            (array_bounds_checker::check_array_ref): Call them.  Handle arrays
            declared in function parameters.
            (array_bounds_checker::check_mem_ref):  Same.  Handle references to
            dynamically allocated arrays.

    gcc/testsuite/ChangeLog:

            PR middle-end/82608
            PR middle-end/94195
            PR c/50584
            PR middle-end/84051
            * c-c++-common/Warray-bounds.c: Adjust.
            * gcc.dg/Wbuiltin-declaration-mismatch-9.c: Adjust.
            * gcc.dg/Warray-bounds-63.c: New test.
            * gcc.dg/Warray-bounds-64.c: New test.
            * gcc.dg/Warray-bounds-65.c: New test.
            * gcc.dg/Warray-bounds-66.c: New test.
            * gcc.dg/Warray-bounds-67.c: New test.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c/50584] No warning for passing small array to C99 static array declarator
  2011-09-30 18:15 [Bug c/50584] New: No warning for passing small array to C99 static array declarator ian at airs dot com
                   ` (14 preceding siblings ...)
  2020-09-19 23:57 ` cvs-commit at gcc dot gnu.org
@ 2020-09-20  0:03 ` msebor at gcc dot gnu.org
  2020-09-21 20:55 ` cvs-commit at gcc dot gnu.org
  16 siblings, 0 replies; 18+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-09-20  0:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
   Target Milestone|---                         |11.0

--- Comment #20 from Martin Sebor <msebor at gcc dot gnu.org> ---
Done for GCC 11.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c/50584] No warning for passing small array to C99 static array declarator
  2011-09-30 18:15 [Bug c/50584] New: No warning for passing small array to C99 static array declarator ian at airs dot com
                   ` (15 preceding siblings ...)
  2020-09-20  0:03 ` msebor at gcc dot gnu.org
@ 2020-09-21 20:55 ` cvs-commit at gcc dot gnu.org
  16 siblings, 0 replies; 18+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-21 20:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50584

--- Comment #21 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:

https://gcc.gnu.org/g:05193687dde2e5a6337164182a1946b584acfada

commit r11-3333-g05193687dde2e5a6337164182a1946b584acfada
Author: Martin Sebor <msebor@redhat.com>
Date:   Mon Sep 21 14:33:29 2020 -0600

    Avoid incidental failures due to implicit attribute access.

    gcc/testsuite/ChangeLog:

            PR c/50584
            * gcc.dg/ipa/ipa-sra-1.c: Use a plain pointer for argv instead of
array.
            * gcc.dg/ipa/ipa-sra-12.c: Same.
            * gcc.dg/ipa/ipa-sra-13.c: Same.
            * gcc.dg/ipa/ipa-sra-14.c: Same.
            * gcc.dg/ipa/ipa-sra-15.c: Same.

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2020-09-21 20:55 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-30 18:15 [Bug c/50584] New: No warning for passing small array to C99 static array declarator ian at airs dot com
2013-02-19  6:51 ` [Bug c/50584] " andi-gcc at firstfloor dot org
2013-08-14  4:46 ` me at minglis dot id.au
2013-08-21 22:34 ` joseph at codesourcery dot com
2013-09-25 10:21 ` me at minglis dot id.au
2014-04-10 12:28 ` jimis at gmx dot net
2014-04-10 12:51 ` mpolacek at gcc dot gnu.org
2015-07-03  1:20 ` sergei.ivn+bugzilla at gmail dot com
2015-07-03  1:41 ` sergei.ivn+bugzilla at gmail dot com
2015-07-03  9:34 ` manu at gcc dot gnu.org
2015-07-03 12:50 ` sergei.ivn+bugzilla at gmail dot com
2020-05-19 20:55 ` msebor at gcc dot gnu.org
2020-07-29  1:25 ` msebor at gcc dot gnu.org
2020-09-19 23:57 ` cvs-commit at gcc dot gnu.org
2020-09-19 23:57 ` cvs-commit at gcc dot gnu.org
2020-09-19 23:57 ` cvs-commit at gcc dot gnu.org
2020-09-20  0:03 ` msebor at gcc dot gnu.org
2020-09-21 20:55 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).