Please don't cross-post to this list and to gcc-help, this question is off-topic here
On Sat, 28 Jul 2018 at 04:01, Vladimir Reshetnikov <[email protected]> wrote: > > I'm trying to understand why gcc rejects the dynamic array allocation in > the initializer of e (introducing an alias or additional parenthesization > suppress the error). Clang and MSVC happily compile this code. Does gcc > correctly reject this code? > > template<typename T> > void f() { > typedef void(*arr[T::value])(); // OK > arr a = { }; // OK > void(*b[T::value])() = { }; // OK > void(**c)() = new arr { }; // OK > void(**d)() = new (void(*[(T::value)])()) { }; // OK > void(**e)() = new (void(*[T::value])()) { }; // error: capture of > non-variable 'T' > } > > struct S { > static constexpr int value = 5; > }; > > int main() { > f<S>(); > } > > Tested against build 9.0.0 20180726 (experimental). > > -- > Thanks > Vladimir
