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

            Bug ID: 125595
           Summary: Using inplace_vector across module boundaries causes
                    corrupt gcm
           Product: gcc
           Version: 16.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eric.nwogbo1 at gmail dot com
  Target Milestone: ---

I'm not sure if its just inplace_vector, and I don't know what its doing to
cause this behaviour, but on "gcc (GCC) 16.1.1 20260515 (Red Hat 16.1.1-2)" if
I try to compile this code I get errors with bad file data:

// a.cppm
export module a;
import std;
export struct S {
    std::inplace_vector<int, 4> v{};
};

// b.cppm
export module b;
import a;
export struct HoldingVector {
    S data;

};
results in:
In module imported at b.cppm:2:1:
a: error: failed to read compiled module cluster 1131: Bad file data
a: note: compiled module file is ‘gcm.cache/a.gcm’
a: error: failed to read compiled module cluster 1134: Bad file data
a: error: failed to read compiled module cluster 1135: Bad file data
b.cppm:4:5: fatal error: failed to load binding ‘::S@a’
    4 |     S data;
      |     ^
I have discovered that using inplace_vector<int, 0> does not have this issue,
and also removing the initializer in the member makes it compile (that writing
std::inplace_vector<int, 4> v;), but if b.cppm initialized data in the same way
it's also seen as bad by other files that import it.

I have a compiler explorer workspace set up with this example (using #include
<inplace_vector> over import std), and it shows gcc trunk giving a completely
different error: https://godbolt.org/z/ox68q1dYT

Reply via email to