public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/101289] New: bogus -Wvla-paramater warning when using const for vla param
@ 2021-07-01 21:45 ljrk at ljrk dot org
2021-07-01 22:43 ` [Bug c/101289] " msebor at gcc dot gnu.org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: ljrk at ljrk dot org @ 2021-07-01 21:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101289
Bug ID: 101289
Summary: bogus -Wvla-paramater warning when using const for vla
param
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: ljrk at ljrk dot org
Target Milestone: ---
Created attachment 51099
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51099&action=edit
minimum working/reproducing example
If the vla parameter has a const specifier, the compiler will warn about
mismatched bounds:
$ cat mwe.c && make CFLAGS=-Wvla-parameter mwe.o
extern void mwe(const int len, char buf[len]);
void mwe(const int len, char buf[len]) {}
cc -Wvla-parameter -c -o mwe.o mwe.c
mwe.c:2:30: warning: argument 2 of type ‘char[len]’ declared with mismatched
bound ‘len’ [-Wvla-parameter]
2 | void mwe(const int len, char buf[len]) {}
| ~~~~~^~~~~~~~
mwe.c:1:37: note: previously declared as ‘char[len]’ with bound ‘len’
1 | extern void mwe(const int len, char buf[len]);
| ~~~~~^~~~~~~~
$
If I remove the const specifier to len, the warning goes away:
$ sed 's/const //g' -i mwe.c && make CFLAGS=-Wvla-parameter mwe.o
cc -Wvla-parameter -c -o mwe.o mwe.c
$
Maybe this is related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97548 ?
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/101289] bogus -Wvla-paramater warning when using const for vla param
2021-07-01 21:45 [Bug c/101289] New: bogus -Wvla-paramater warning when using const for vla param ljrk at ljrk dot org
@ 2021-07-01 22:43 ` msebor at gcc dot gnu.org
2021-07-01 22:44 ` msebor at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-07-01 22:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101289
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |11.2
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
CC| |msebor at gcc dot gnu.org
Last reconfirmed| |2021-07-01
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed. The root cause is the same as in pr97548 even though the test case
here is quite different. They're both worth adding to the test suite.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/101289] bogus -Wvla-paramater warning when using const for vla param
2021-07-01 21:45 [Bug c/101289] New: bogus -Wvla-paramater warning when using const for vla param ljrk at ljrk dot org
2021-07-01 22:43 ` [Bug c/101289] " msebor at gcc dot gnu.org
@ 2021-07-01 22:44 ` msebor at gcc dot gnu.org
2021-07-02 1:04 ` msebor at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-07-01 22:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101289
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org
Depends on| |97548
Status|NEW |ASSIGNED
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97548
[Bug 97548] bogus -Wvla-parameter on a bound expression involving a parameter
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/101289] bogus -Wvla-paramater warning when using const for vla param
2021-07-01 21:45 [Bug c/101289] New: bogus -Wvla-paramater warning when using const for vla param ljrk at ljrk dot org
2021-07-01 22:43 ` [Bug c/101289] " msebor at gcc dot gnu.org
2021-07-01 22:44 ` msebor at gcc dot gnu.org
@ 2021-07-02 1:04 ` msebor at gcc dot gnu.org
2021-07-15 16:23 ` cvs-commit at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-07-02 1:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101289
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
Known to fail| |11.1.0, 12.0
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Patch: https://gcc.gnu.org/pipermail/gcc-patches/2021-July/574310.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/101289] bogus -Wvla-paramater warning when using const for vla param
2021-07-01 21:45 [Bug c/101289] New: bogus -Wvla-paramater warning when using const for vla param ljrk at ljrk dot org
` (2 preceding siblings ...)
2021-07-02 1:04 ` msebor at gcc dot gnu.org
@ 2021-07-15 16:23 ` cvs-commit at gcc dot gnu.org
2021-07-15 16:25 ` msebor at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-15 16:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101289
--- Comment #3 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:98f1f9f38c45218c06200feb1939c9433a2ab6ca
commit r12-2329-g98f1f9f38c45218c06200feb1939c9433a2ab6ca
Author: Martin Sebor <msebor@redhat.com>
Date: Thu Jul 15 10:11:23 2021 -0600
Avoid -Wvla-parameter for nontrivial bounds [PR97548].
Resolves:
PR c/101289 - bogus -Wvla-paramater warning when using const for vla param
PR c/97548 - bogus -Wvla-parameter on a bound expression involving a
parameter
gcc/c-family/ChangeLog:
PR c/101289
PR c/97548
* c-warn.c (warn_parm_array_mismatch): Use OEP_DECL_NAME.
gcc/c/ChangeLog:
PR c/101289
PR c/97548
* c-decl.c (get_parm_array_spec): Strip nops.
gcc/ChangeLog:
PR c/101289
PR c/97548
* fold-const.c (operand_compare::operand_equal_p): Handle
OEP_DECL_NAME.
(operand_compare::verify_hash_value): Same.
* tree-core.h (OEP_DECL_NAME): New.
gcc/testsuite/ChangeLog:
* gcc.dg/Wvla-parameter-12.c: New test.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/101289] bogus -Wvla-paramater warning when using const for vla param
2021-07-01 21:45 [Bug c/101289] New: bogus -Wvla-paramater warning when using const for vla param ljrk at ljrk dot org
` (3 preceding siblings ...)
2021-07-15 16:23 ` cvs-commit at gcc dot gnu.org
@ 2021-07-15 16:25 ` msebor at gcc dot gnu.org
2021-07-23 19:44 ` [Bug c/101289] [11 Regression] " msebor at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-07-15 16:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101289
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail|12.0 |
--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
Fixed for GCC 12.0.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/101289] [11 Regression] bogus -Wvla-paramater warning when using const for vla param
2021-07-01 21:45 [Bug c/101289] New: bogus -Wvla-paramater warning when using const for vla param ljrk at ljrk dot org
` (4 preceding siblings ...)
2021-07-15 16:25 ` msebor at gcc dot gnu.org
@ 2021-07-23 19:44 ` msebor at gcc dot gnu.org
2021-07-28 7:07 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-07-23 19:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101289
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|bogus -Wvla-paramater |[11 Regression] bogus
|warning when using const |-Wvla-paramater warning
|for vla param |when using const for vla
| |param
--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
I'll backport the patch into GCC 11.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/101289] [11 Regression] bogus -Wvla-paramater warning when using const for vla param
2021-07-01 21:45 [Bug c/101289] New: bogus -Wvla-paramater warning when using const for vla param ljrk at ljrk dot org
` (5 preceding siblings ...)
2021-07-23 19:44 ` [Bug c/101289] [11 Regression] " msebor at gcc dot gnu.org
@ 2021-07-28 7:07 ` rguenth at gcc dot gnu.org
2021-12-16 22:47 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-28 7:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101289
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|11.2 |11.3
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11.2 is being released, retargeting bugs to GCC 11.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/101289] [11 Regression] bogus -Wvla-paramater warning when using const for vla param
2021-07-01 21:45 [Bug c/101289] New: bogus -Wvla-paramater warning when using const for vla param ljrk at ljrk dot org
` (6 preceding siblings ...)
2021-07-28 7:07 ` rguenth at gcc dot gnu.org
@ 2021-12-16 22:47 ` cvs-commit at gcc dot gnu.org
2021-12-16 22:48 ` msebor at gcc dot gnu.org
2022-03-17 19:45 ` msebor at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-12-16 22:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101289
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Martin Sebor
<msebor@gcc.gnu.org>:
https://gcc.gnu.org/g:7d3f53c595e1766ca0494e5f56f33b0ce49b3bb4
commit r11-9396-g7d3f53c595e1766ca0494e5f56f33b0ce49b3bb4
Author: Martin Sebor <msebor@redhat.com>
Date: Thu Jul 15 10:11:23 2021 -0600
Avoid -Wvla-parameter for nontrivial bounds [PR97548].
Resolves:
PR c/101289 - bogus -Wvla-paramater warning when using const for vla param
PR c/97548 - bogus -Wvla-parameter on a bound expression involving a
parameter
gcc/c-family/ChangeLog:
PR c/101289
PR c/97548
* c-warn.c (warn_parm_array_mismatch): Use OEP_DECL_NAME.
gcc/c/ChangeLog:
PR c/101289
PR c/97548
* c-decl.c (get_parm_array_spec): Strip nops.
gcc/ChangeLog:
PR c/101289
PR c/97548
* fold-const.c (operand_compare::operand_equal_p): Handle
OEP_DECL_NAME.
(operand_compare::verify_hash_value): Same.
* tree-core.h (OEP_DECL_NAME): New.
gcc/testsuite/ChangeLog:
* gcc.dg/Wvla-parameter-12.c: New test.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/101289] [11 Regression] bogus -Wvla-paramater warning when using const for vla param
2021-07-01 21:45 [Bug c/101289] New: bogus -Wvla-paramater warning when using const for vla param ljrk at ljrk dot org
` (7 preceding siblings ...)
2021-12-16 22:47 ` cvs-commit at gcc dot gnu.org
@ 2021-12-16 22:48 ` msebor at gcc dot gnu.org
2022-03-17 19:45 ` msebor at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-12-16 22:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101289
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #8 from Martin Sebor <msebor at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/101289] [11 Regression] bogus -Wvla-paramater warning when using const for vla param
2021-07-01 21:45 [Bug c/101289] New: bogus -Wvla-paramater warning when using const for vla param ljrk at ljrk dot org
` (8 preceding siblings ...)
2021-12-16 22:48 ` msebor at gcc dot gnu.org
@ 2022-03-17 19:45 ` msebor at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: msebor at gcc dot gnu.org @ 2022-03-17 19:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101289
Bug 101289 depends on bug 97548, which changed state.
Bug 97548 Summary: [11 Regression] bogus -Wvla-parameter on a bound expression involving a parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97548
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2022-03-17 19:45 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-01 21:45 [Bug c/101289] New: bogus -Wvla-paramater warning when using const for vla param ljrk at ljrk dot org
2021-07-01 22:43 ` [Bug c/101289] " msebor at gcc dot gnu.org
2021-07-01 22:44 ` msebor at gcc dot gnu.org
2021-07-02 1:04 ` msebor at gcc dot gnu.org
2021-07-15 16:23 ` cvs-commit at gcc dot gnu.org
2021-07-15 16:25 ` msebor at gcc dot gnu.org
2021-07-23 19:44 ` [Bug c/101289] [11 Regression] " msebor at gcc dot gnu.org
2021-07-28 7:07 ` rguenth at gcc dot gnu.org
2021-12-16 22:47 ` cvs-commit at gcc dot gnu.org
2021-12-16 22:48 ` msebor at gcc dot gnu.org
2022-03-17 19:45 ` msebor 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).