You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] requires clause does not appear in "cpp2 type definitions and function declaration" causing out-of-line definition error #323
Trying to compile that with cpp1 compiler (Apple clang version 14.0.3 in my case):
../tests/bug_assignement_operator_5.cpp2... ok (all Cpp2, passes safety checks)
../tests/bug_assignement_operator_5.cpp2:4:14: error: out-of-line definition of 'element' does not match any declaration in 'element'
element::element(auto&& n)
^~~~~~~
../tests/bug_assignement_operator_5.cpp2:4:19: error: out-of-line definition of 'operator=' does not match any declaration in 'element'
auto element::operator=(auto&& n) -> element&
^~~~~~~~
2 errors generated.
The fix is pretty straightforward - requires clause must also appear in the Cpp2 type definitions and function declarations section (I have changed that manually, and it works).
I think the test happens to work, despite #323, because the definition overloads with the declaration. So actually not emitting the requires on the declaration wouldn't be a fix even for GCC 10.
-- #477 (comment)
It wants to call the unconstrained forward declaration!
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/14.0.0/../../../../x86_64-linux-gnu/bin/ld: CMakeFiles/test.dir/_cppfront/main.cpp.o: in function `main':
main.cpp:(.text+0x14): undefined reference to `void f<int>(int&&)'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Activity
filipsajdak commentedon Apr 5, 2023
While looking for a place on how to fix it, I have found comments:
cppfront/source/cppfront.cpp
Lines 5110 to 5129 in 827ed79
And the
(A)location is here:cppfront/source/cppfront.cpp
Line 5013 in 827ed79
filipsajdak commentedon Apr 5, 2023
@hsutter regarding gcc-11 installation on Ubuntu 20.04 - have you tried #293 (comment) ?
TLDR: you can install
gcc-11andg++-11with:JohelEGP commentedon May 31, 2023
JohelEGP commentedon Jun 1, 2023
GCC not-10 is also broken: https://cpp2.godbolt.org/z/MsY89sMxh.
We shouldn't be deprived of requires clauses for GCC 10. Nerf it.
JohelEGP commentedon Jun 7, 2023
Proof that not emitting
requiresmakes an overload set: https://cpp2.godbolt.org/z/PrEqz4nW6.It wants to call the unconstrained forward declaration!