https://bugs.llvm.org/show_bug.cgi?id=50346
Bug ID: 50346
Summary: Implicitly-defined default constructor not generated
for nested class
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangb...@nondot.org
Reporter: alex.franc...@gmail.com
CC: blitzrak...@gmail.com, dgre...@apple.com,
erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
richard-l...@metafoo.co.uk
Code sample:
#include <optional>
struct Outer {
struct Inner {
int a = 0;
};
std::optional<Inner> inner;
};
int main() {
Outer o;
o.inner.emplace();
return 0;
}
https://godbolt.org/z/jKoG9a7e4
In the above, the `emplace()` call causes an error, stating that the class
(`Outer::Inner`) does not have a constructor that matches the arguments. Note
that this is specifically an issue in combination with libstdc++'s impl of
std::optional; libc++ (since clang 9) seems to work (though prior to clang 9 it
generates the same error).
If you do `std::optional<Outer::Inner>`, it also fails (though it will succeed
if you remove the `inner` member).
If you change `int a = 0` to `int a` (without the default value), it will
succeed.
If you add an `Inner() = default`, it still fails, however adding `Inner() {}`
will make it succeed.
This may be loosely related to bug 15886.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs