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

            Bug ID: 116789
           Summary: Internal compiler error for non-type template
                    parameter to alias template inside macro
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: aslobodkins at mail dot smu.edu
  Target Milestone: ---

I get the following error on all versions of gcc13 and gcc14 I have tried so
far(includes gcc-14.1 and gcc-14.2):

In file included from ../src/Expr/array_expr1D.hpp:9,
                 from ../src/strict_lib.hpp:8,
                 from test.hpp:6,
                 from fixed_array.cpp:8:
../src/Expr/../derived1D.hpp: In substitution of ‘template<class T,
slib::ImplicitIntStatic sz>  requires  Builtin<T> using slib::FixedArray1D =
slib::Derived1D<slib::FixedArrayBase1D<T, ((const slib::ImplicitIntStatic)N)> >
[with slib::ImplicitIntStatic sz = T]’:
fixed_array.cpp:64:4:   required from here
../src/Expr/../derived1D.hpp:994:7: internal compiler error: Segmentation fault
  994 | using FixedArray1D = Derived1D<FixedArrayBase1D<T, sz>>;
      |       ^~~~~~~~~~~~

The error occurs in the following scenario:  
constexpr FixedArray1D<T, 5> A;
REQUIRE_STRICT_THROW((FixedArray1D<T, A.size_m1()>(A.begin(), A.end())));

where REQUIRE_STRICT_THROW is a macro that tests error handling and triggers
assertion if the passed expression does not throw. 

It is important to point out that this error does not occur if one calls
standard size() function:
REQUIRE_STRICT_THROW((FixedArray1D<T, A.size()>(A.begin(), A.end())));

In addition, removing REQUIRE_STRICT_THROW gets rid of the issue as well:
FixedArray1D<T, A.size_m1()>(A.begin(), A.end());

Finally, replacing FixedArray1D alias with Derived1D<FixedArrayBase1D> also
works fine:
REQUIRE_STRICT_THROW((Derived1D<FixedArrayBase1D<T, A.size_m1()>>(A.begin(),
A.end())));

Reply via email to