[Bug c++/97234] Constexpr class-scope array initializer referencing previous elements
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97234 Botond Ballo changed: What|Removed |Added See Also||https://gcc.gnu.org/bugzill ||a/show_bug.cgi?id=99059 --- Comment #3 from Botond Ballo --- Bug 99059 is similar (involving C++17 "inline" rather than constexpr) and Jonathan Wakely said it's a bug.
[Bug c++/97234] Constexpr class-scope array initializer referencing previous elements
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97234 --- Comment #2 from Botond Ballo --- I believe it's valid because the point of declaration of a variable is just before its initializer (https://timsong-cpp.github.io/cppwp/n4861/basic.scope.pdecl#1), and thus the variable should be in scope in its initializer. But I'm not a wording expert and it's possible I'm mistaken, or overlooking something else that would make this invalid.
[Bug c++/100644] New: [11 regression] Deleted move constructor prevents templated constructor from being used
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100644 Bug ID: 100644 Summary: [11 regression] Deleted move constructor prevents templated constructor from being used Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: botond at mozilla dot com Target Milestone: --- GCC 11 gives an error for the following code which GCC 10 and Clang accept: struct NonMovable { NonMovable(NonMovable&&) = delete; }; template struct Maybe { NonMovable mMember; template Maybe(Maybe&&); }; void foo(Maybe); void unlucky(Maybe&& x) { Maybe var{(Maybe&&)x}; } The error is: main.cpp: In function ‘void unlucky(Maybe&&)’: main.cpp:16:33: error: use of deleted function ‘Maybe::Maybe(Maybe&&)’ 16 | Maybe var{(Maybe&&)x}; | ^ main.cpp:6:8: note: ‘Maybe::Maybe(Maybe&&)’ is implicitly deleted because the default definition would be ill-formed: 6 | struct Maybe { |^ main.cpp:6:8: error: use of deleted function ‘NonMovable::NonMovable(NonMovable&&)’ main.cpp:2:3: note: declared here 2 | NonMovable(NonMovable &&) = delete; | ^~ I believe the code should be accepted, with the deleted move constructor ignored during overload resolution and the templated constructor used instead. I explain my reasoning, with links to the standard, in more detail here: https://bugzilla.mozilla.org/show_bug.cgi?id=1710235#c22 Please let me know if I've overlooked something and the code really is invalid.
[Bug c++/97234] New: Constexpr class-scope array initializer referencing previous elements
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97234 Bug ID: 97234 Summary: Constexpr class-scope array initializer referencing previous elements Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: botond at mozilla dot com Target Milestone: --- The following code: struct S { static constexpr int rolling_sum[4]{ 0, rolling_sum[0] + 1, rolling_sum[1] + 2, rolling_sum[2] + 3 }; }; produces errors when compiled with g++ 10: test.cpp:4:9: error: ‘rolling_sum’ was not declared in this scope 4 | rolling_sum[0] + 1, | ^~~ test.cpp:5:9: error: ‘rolling_sum’ was not declared in this scope 5 | rolling_sum[1] + 2, | ^~~ test.cpp:6:9: error: ‘rolling_sum’ was not declared in this scope 6 | rolling_sum[2] + 3 | The code is accepted by clang. It's also accepted by gcc if the array is declared at namespace scope, leading me to believe that rejecting it at class scope is likely a bug.