public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97820] New: VLAs in function declarations fail to compile
@ 2020-11-13 20:04 josephcsible at gmail dot com
  2020-11-19 18:35 ` [Bug c++/97820] " mpolacek at gcc dot gnu.org
  2024-03-30 19:18 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: josephcsible at gmail dot com @ 2020-11-13 20:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97820
           Summary: VLAs in function declarations fail to compile
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: josephcsible at gmail dot com
  Target Milestone: ---

Consider these 4 attempts at declaring a function:

void f1(int rows, int cols, int arr[rows][cols]);
void f2(int rows, int cols, int (*arr)[cols]);
void f3(int, int, int [*][*]);
void f4(int, int, int (*)[*]);

When I compile them with g++, they all have errors:

<source>:1:41: error: use of parameter outside function body before ']' token
    1 | void f1(int rows, int cols, int arr[rows][cols]);
      |                                         ^
<source>:1:47: error: use of parameter outside function body before ']' token
    1 | void f1(int rows, int cols, int arr[rows][cols]);
      |                                               ^
<source>:2:44: error: use of parameter outside function body before ']' token
    2 | void f2(int rows, int cols, int (*arr)[cols]);
      |                                            ^
<source>:3:25: error: expected primary-expression before ']' token
    3 | void f3(int, int, int [*][*]);
      |                         ^
<source>:3:28: error: expected primary-expression before ']' token
    3 | void f3(int, int, int [*][*]);
      |                            ^
<source>:4:28: error: expected primary-expression before ']' token
    4 | void f4(int, int, int (*)[*]);
      |                            ^

Since we support VLAs in C++ as an extension, I expected that all of these
would work.

https://godbolt.org/z/Wca9ra

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

* [Bug c++/97820] VLAs in function declarations fail to compile
  2020-11-13 20:04 [Bug c++/97820] New: VLAs in function declarations fail to compile josephcsible at gmail dot com
@ 2020-11-19 18:35 ` mpolacek at gcc dot gnu.org
  2024-03-30 19:18 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-11-19 18:35 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-11-19
                 CC|                            |mpolacek at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.  Not a regression.

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

* [Bug c++/97820] VLAs in function declarations fail to compile
  2020-11-13 20:04 [Bug c++/97820] New: VLAs in function declarations fail to compile josephcsible at gmail dot com
  2020-11-19 18:35 ` [Bug c++/97820] " mpolacek at gcc dot gnu.org
@ 2024-03-30 19:18 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-30 19:18 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=51352

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This might be a dup of bug 51352 .

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

end of thread, other threads:[~2024-03-30 19:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-13 20:04 [Bug c++/97820] New: VLAs in function declarations fail to compile josephcsible at gmail dot com
2020-11-19 18:35 ` [Bug c++/97820] " mpolacek at gcc dot gnu.org
2024-03-30 19:18 ` 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).