| Issue |
178893
|
| Summary |
[clang][modules] miscompilation of lambda expressions with `-fno-modules-reduced-bmi`
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
jiixyj
|
This code returns "1" instead of "0":
```c++
export module foo;
namespace foo {
struct format {
static inline int parse(int* i) {
return [&] -> int { return i[0]; }();
volatile bool b = false;
if (b) {
auto identifier = [&] -> int { return i[1]; }();
return identifier;
}
}
};
} // namespace foo
extern "C++" int main() {
int n[2] = {0, 1};
return foo::format::parse(n);
}
```
Somehow the compiler confuses the two lambdas, i.e. in the `return` line the second lambda is called instead of the first.
Godbolt link: <https://godbolt.org/z/46nKjz3rz>
The clang command line arguments are: "-O2 -g -std=c++26 -fno-modules-reduced-bmi -x c++-module"
@ChuanqiXu9 : This is the issue I mentioned at <https://github.com/llvm/llvm-project/issues/177385#issuecomment-3799220187>. Reverting https://github.com/llvm/llvm-project/commit/772b15b3be153b1d2df910057af17926ea227243 and https://github.com/llvm/llvm-project/commit/5937d7f907ef656abb16622c8b4e72fe906e9328 fixes it.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs