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
import mod;
intmain ()
{
autoconst s1 = s{};
autoconst f = s1.make_lambda();
autoconst g = f; // error here
}
As above, the code will fail on both: however clang will report an unavailable copy constructor whereas gcc compiles but raises a multiple definition linker error. With a captured this, gcc is happy but clang continues to give the same compilation error. Making the member function inline fixes the problem on both.
I'm not certain what the correct behaviour should be here, but either one of clang and gcc is wrong, and even if clang is correct it seems the error messages could be better.
The following code leads to some somewhat unintuitive error messages, and has some behaviour differences in comparison to gcc.
```
export module mod;
export struct s
{
/inline/ auto make_lambda() const
{
return [/this/]{};
}
};
import mod;
int main ()
{
auto const s1 = s{};
auto const f = s1.make_lambda();
auto const g = f; // error here
}
As above, the code will fail on both: however clang will report an unavailable copy constructor whereas gcc compiles but raises a multiple definition linker error. With a captured `this`, gcc is happy but clang continues to give the same compilation error. Making the member function `inline` fixes the problem on both.
I'm not certain what the correct behaviour should be here, but either one of clang and gcc is wrong, and even if clang is correct it seems the error messages could be better.
Compiler explorer repro: https://godbolt.org/z/Knfjf3aMe.
</details>
The following code leads to some somewhat unintuitive error messages, and has some behaviour differences in comparison to gcc.
As above, the code will fail on both: however clang will report an unavailable copy constructor whereas gcc compiles but raises a multiple definition linker error. With a captured
this
, gcc is happy but clang continues to give the same compilation error. Making the member functioninline
fixes the problem on both.I'm not certain what the correct behaviour should be here, but either one of clang and gcc is wrong, and even if clang is correct it seems the error messages could be better.
Compiler explorer repro: https://godbolt.org/z/Knfjf3aMe.
The text was updated successfully, but these errors were encountered: