Einige bestimmte Voraussetzungen müssen erfüllt sein, bevor es reproduziert wird:
Code: Select all
#include
/// Precondition #1: T must be a nested struct
struct Foo
{
struct Victim
{
/// Precondition #2: T must have an aggregate-initializer
/// for one of its members
std::size_t value{0};
};
/// Precondition #3: std::optional must be instantiated in this scope
std::optional victim;
bool foo()
{
std::optional foo;
// An error
foo.emplace();
/// Assertion is failed
static_assert(std::is_constructible::value);
}
};
Live-Beispiel auf godbolt.org
Ändern Sie eine der Vorbedingungen und es wird wie erwartet kompiliert. Gibt es eine unbekannte Inkonsistenz im Standard, die dazu führt, dass Clang diesen Code ablehnt, obwohl er konform ist?
Als Randbemerkung: GCC 7.1 und GCC 7.2 haben kein Problem mit dem oben genannten Code.
Fehlerbericht unter: bugs.llvm.org
Mobile version