public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109775] New: gcc misidentifies a VLA
@ 2023-05-08 16:07 janezz55 at gmail dot com
2023-05-08 16:13 ` [Bug c++/109775] " pinskia at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: janezz55 at gmail dot com @ 2023-05-08 16:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109775
Bug ID: 109775
Summary: gcc misidentifies a VLA
Product: gcc
Version: 13.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: janezz55 at gmail dot com
Target Milestone: ---
If I compile the example .cpp file:
gcc -std=c++20 -Wextra -Wall -Wpedantic add_sub_tests.cpp -o a
gcc produces the warning:
../intt.hpp: In member function 'constexpr auto intt::intt<
<template-parameter-1-1>, N, <anonymous> >::naimul(const intt::intt<
<template-parameter-1-1>, N, <anonymous> >&) const':
../intt.hpp:675:24: warning: ISO C++ forbids variable length array 'v_' [-Wvla]
675 | D const pp(D(v_[i]) * o.v_[S - i]);
| ^~
But no VLA is involved and clang++ 15 manages to avoid this issue.
The example file is here:
https://github.com/user1095108/intt/blob/master/tests/add_sub_tests.cpp
I believe the bug was present in prior versions of gcc as well.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/109775] gcc misidentifies a VLA
2023-05-08 16:07 [Bug c++/109775] New: gcc misidentifies a VLA janezz55 at gmail dot com
@ 2023-05-08 16:13 ` pinskia at gcc dot gnu.org
2023-05-08 16:17 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-08 16:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109775
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
It has to do with parsing here:
GCC starts parsing it as a function declaration and then backs out but had
already warned/errored out about the VLA.
If you change the code to:
D const pp{D(v_[i]) * o.v_[S - i]};
Then there is no ambiguity in parsing this.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/109775] gcc misidentifies a VLA
2023-05-08 16:07 [Bug c++/109775] New: gcc misidentifies a VLA janezz55 at gmail dot com
2023-05-08 16:13 ` [Bug c++/109775] " pinskia at gcc dot gnu.org
@ 2023-05-08 16:17 ` pinskia at gcc dot gnu.org
2023-05-08 16:46 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-08 16:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109775
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 55022
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55022&action=edit
Non reduced testcase
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/109775] gcc misidentifies a VLA
2023-05-08 16:07 [Bug c++/109775] New: gcc misidentifies a VLA janezz55 at gmail dot com
2023-05-08 16:13 ` [Bug c++/109775] " pinskia at gcc dot gnu.org
2023-05-08 16:17 ` pinskia at gcc dot gnu.org
@ 2023-05-08 16:46 ` pinskia at gcc dot gnu.org
2023-05-08 16:48 ` pinskia at gcc dot gnu.org
2023-05-08 16:49 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-08 16:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109775
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-05-08
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced testcase:
```
template <typename T>
constexpr void naimul(const T v_[2])
{
int i = 1;
T pp(T(v_[i])+0);
}
```
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/109775] gcc misidentifies a VLA
2023-05-08 16:07 [Bug c++/109775] New: gcc misidentifies a VLA janezz55 at gmail dot com
` (2 preceding siblings ...)
2023-05-08 16:46 ` pinskia at gcc dot gnu.org
@ 2023-05-08 16:48 ` pinskia at gcc dot gnu.org
2023-05-08 16:49 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-08 16:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109775
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Here is another related testcase:
```
typedef int T;
void naimul(const T v_[2])
{
int i = 0;
T pp(T(v_[0])+0);
}
```
We get an -pedantic-error dealing with 0 sized array:
<source>: In function 'void naimul(const T*)':
<source>:5:13: error: ISO C++ forbids zero-size array 'v_' [-Wpedantic]
5 | T pp(T(v_[0])+0);
| ^
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/109775] gcc misidentifies a VLA
2023-05-08 16:07 [Bug c++/109775] New: gcc misidentifies a VLA janezz55 at gmail dot com
` (3 preceding siblings ...)
2023-05-08 16:48 ` pinskia at gcc dot gnu.org
@ 2023-05-08 16:49 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-08 16:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109775
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Depends on| |61259
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> Here is another related testcase:
> ```
> typedef int T;
> void naimul(const T v_[2])
> {
> int i = 0;
> T pp(T(v_[0])+0);
> }
> ```
> We get an -pedantic-error dealing with 0 sized array:
> <source>: In function 'void naimul(const T*)':
> <source>:5:13: error: ISO C++ forbids zero-size array 'v_' [-Wpedantic]
> 5 | T pp(T(v_[0])+0);
> | ^
That is recorded as PR 61259 .
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61259
[Bug 61259] [10/11/12/13/14 Regression] Spurious "ISO C++ forbids zero-size
array" warning with -pedantic
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-05-08 16:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-08 16:07 [Bug c++/109775] New: gcc misidentifies a VLA janezz55 at gmail dot com
2023-05-08 16:13 ` [Bug c++/109775] " pinskia at gcc dot gnu.org
2023-05-08 16:17 ` pinskia at gcc dot gnu.org
2023-05-08 16:46 ` pinskia at gcc dot gnu.org
2023-05-08 16:48 ` pinskia at gcc dot gnu.org
2023-05-08 16:49 ` pinskia 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).