-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Describe the bug
std::array<T,0> doesn't compile - when type has private default constructor, deleted default constructor, or no default constructor.
If there's a default constructor, it is called once during std::array<T,0> construction.
According to LWG-2157, there should be a single element of unspecificed type, and such array should be still default constructible.
Command-line test case
D:\Temp2>type repro.cpp
#include <array>
struct NonDefault {
NonDefault() = delete;
NonDefault(int) {}
};
std::array<NonDefault, 0> a;
int main() {
}
D:\Temp2>cl /EHsc /W4 /WX .\repro.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.27.29009.1 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
repro.cpp
.\repro.cpp(8): error C2280: 'std::array<NonDefault,0>::array(void)': attempting to reference a deleted function
c:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\include\array(770): note: compiler has generated 'std::array<NonDefault,0>::array' here
c:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\include\array(770): note: 'std::array<NonDefault,0>::array(void)': function was implicitly deleted because a data member invokes a deleted or inaccessible function 'NonDefault::NonDefault(void)'
.\repro.cpp(4): note: 'NonDefault::NonDefault(void)': function was explicitly deleted
Expected behavior
Test compiles, links and runs.
STL version
Microsoft Visual Studio Professional 2019 Preview
Version 16.7.0 Preview 3.1
Additional context
- Skipped libcxx test:
STL/tests/libcxx/expected_results.txt
Lines 576 to 581 in 06827fe
# STL bug: VSO-207715 We reject array<NoDefault, 0>. std/containers/sequences/array/array.cons/implicit_copy.pass.cpp FAIL std/containers/sequences/array/array.cons/initialization.pass.cpp FAIL std/containers/sequences/array/array.data/data_const.pass.cpp FAIL std/containers/sequences/array/array.data/data.pass.cpp FAIL std/containers/sequences/array/iterators.pass.cpp FAIL
This item is also tracked on Developer Community as DevCom-329888, and by Microsoft-internal VSO-207715 / AB#207715.
vNext note: Resolving this issue will require breaking binary compatibility. We won't be able to accept pull requests for this issue until the vNext branch is available. See #169 for more information.