https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98362
Bug ID: 98362
Summary: bad file data on Windows for C++ 20 module
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: unlvsur at live dot com
Target Milestone: ---
I guess the reason is because of CRLF issue. You need to open module file with
_O_BINARY flag. Or msvcrt or ucrt will trigger them as a text stream. I guess
that is the solution
E:\mingw-w64-backup\msys64\home\unlvs\www>g++ -o main hello.cc main.cc -Ofast
-std=c++20 -s -fmodules-ts
In module imported at main.cc:1:1:
hello: error: failed to read compiled module: Bad file data
hello: note: compiled module file is 'gcm.cache/hello.gcm'
hello: fatal error: returning to the gate for a mechanical issue
compilation terminated.
hello.cc
module;
#include<cstdio>
export module hello;
export inline void greeter (char const* cstr) noexcept
{
std::puts(cstr);
}
main.cc
import hello;
int main (void)
{
greeter("Hello\n");
}