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

            Bug ID: 86717
           Summary: Unexpected error in dynamic allocation of an array of
                    function pointers
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: v.reshetnikov at gmail dot com
  Target Milestone: ---

/****************** BEGIN SOURCE ******************/
template<typename T>
void f() {
    typedef void(*arr[T::value])();
    new arr;                     // OK
    new (void(*[(T::value)])()); // OK
    new (void(*[T::value])());   // error: capture of non-variable 'T'
}

struct S {
    static constexpr int value = 5;
};

int main() {
    f<S>();
}
/******************* END SOURCE *******************/

The last new-expression is rejected (as I believe, incorrectly). For
comparison, clang and MSVC compile this code successfully.

Tested with build 9.0.0 20180726 (experimental).

Reply via email to