Why does NVCC not like default-initialization of std::arrays?

Viewed 97

Consider the following program:

#include <array>

int main() {
        struct A {
                bool valid = true;
                ~A() { valid = false; }
        };

        const std::array<A, 1> a;
        const A& aa = a.at(0);
        return aa.valid;
}

This is what I get when I compile it with g++ and nvcc, respectively:

$ g++ -Wall -std=c++14  -o a -x c++ a.cu
$ nvcc --std=c++14 -o a a.cu
a.cu(9): warning: const variable "a" requires an initializer -- class "std::array<A, 1UL>" has no user-provided default constructor

a.cu(9): warning: const variable "a" requires an initializer -- class "std::array<A, 1UL>" has no user-provided default constructor

Why this warning? Isn't there a default constructor for the array? GCC seems to think that there is.

Notes:

  • Using NVCC 10.1 on Devuan GNU/Linux 3.
  • Same results if I use --std=c++11.
0 Answers
Related