https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121724

            Bug ID: 121724
           Summary: Bad file data error on modules with nested namespace
                    that does not match with global module fragment
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: shach.nkku at gmail dot com
  Target Milestone: ---

The following code fails to compile with Bad file data error.
The error was reproduced locally with g++ 14.3.0 and 15.1.0, and also on
wandbox with g++ 11.4.0, 12.3.0, 13.2.0 and 16.0.0 20250729:
https://wandbox.org/permlink/Mhd2nbX2BQsf3C7H

foo.h:
```
namespace A {
inline namespace X {
namespace B {
}
}
}
```

foo.cc:
```
module;
#include "./foo.h"
export module foo;
export namespace A {
namespace B {
}
}
```

main.cc:
```
import foo;
int main(){}
```

command line: g++ -std=c++20 -fmodules-ts ./foo.cc ./main.cc

output:
```
In module imported at ./main.cc:1:1:
foo: error: failed to read compiled module: Bad file data
foo: note: compiled module file is 'gcm.cache/foo.gcm'
foo: fatal error: returning to the gate for a mechanical issue
compilation terminated.
```

The error disappears if `inline` in foo.h was removed, or `inline namespace X`
was inserted in foo.cc.

Reply via email to