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.

Reply via email to