[llvm-bugs] [Bug 50346] New: Implicitly-defined default constructor not generated for nested class
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri May 14 12:18:19 PDT 2021
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: unassignedclangbugs at nondot.org
Reporter: alex.franchuk at gmail.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210514/c6f4781b/attachment.html>
More information about the llvm-bugs
mailing list