Fwd: Dynamically allocated array of function pointers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux