-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Closed
Closed
Copy link
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++20clang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.clang:modulesC++20 modules and Clang Header ModulesC++20 modules and Clang Header Modules
Description
Bugzilla Link | 52531 |
Version | trunk |
OS | All |
Reporter | LLVM Bugzilla Contributor |
CC | @dwblaikie,@zygoloid |
Extended Description
I met an interesting bug which would happen only if iosstream and module file end with .cppm
.
Here is the reproducer:
// Hello.cppm
module;
#include <iostream>
export module Hello;
export void SayHello()
{
std::cout << "Hello World.\n";
}
// main.cpp
import Hello;
int main() {
SayHello();
return 0;
}
And if I compile it as:
clang++ -std=c++20 --precompile Hello.cppm -o Hello.pcm
clang++ -std=c++20 -fprebuilt-module-path=. Hello.pcm main.cpp
And the generated executable would crash.
Interestingly, it wouldn't crash if we use std::printf
instead of std::cout
// Hello.cppm
module;
#include <cstdio>
export module Hello;
export void SayHello()
{
std::printf("Hello World.\n");
}
// main.cpp
import Hello;
int main() {
SayHello();
return 0;
}
Also, it wouldn't crash if the suffix is cpp
instead of cppm
. For example:
// Hello.cpp
module;
#include <iostream>
export module Hello;
export void SayHello()
{
std::cout << "Hello World.\n";
}
// main.cpp
import Hello;
int main() {
SayHello();
return 0;
}
Compile argument:
clang++ -std=c++20 -Xclang -emit-module-interface Hello.cpp -o Hello.pcm
clang++ -std=c++20 -fprebuilt-module-path=. say_hello.cpp main.cpp
I am not sure if this is a bug in compiler or in runtime. It is appreciate if someone could help to confirm this.
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++20clang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.clang:modulesC++20 modules and Clang Header ModulesC++20 modules and Clang Header Modules