[Bug c++/124309] [modules] "Bad import dependency" when partition and primary interface share a transitive import
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 12 23:39:08 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124309
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathaniel Shead <nshead@gcc.gnu.org>:
https://gcc.gnu.org/g:5258acb60d81e532814275fccb50cec98ca17fc7
commit r16-8066-g5258acb60d81e532814275fccb50cec98ca17fc7
Author: Nathaniel Shead <nathanieloshead@gmail.com>
Date: Mon Mar 9 01:10:02 2026 +1100
c++/modules: Reparent linemaps for partition direct loads [PR124309]
The attached testcase failed because when part-11_d.C sees the import
of X through Z:part, the module's location is maintained as the indirect
(imported) location through Y that came first, but it is still promoted
to a direct import.
When part-11_e.C reads the module then it sees a direct import of X
through Z, but there is no valid source location for X in Z (because we
only kept the imported location) and so we report a bad CMI.
This fixes the issue by updating a module seen as direct for the first
time via a partition to reparent the module's location to where the
partition imported it from, so we properly process it as a direct
location that we need to write out, similarly to what we do when we
reimport an indirect module within the module purview.
PR c++/124309
gcc/cp/ChangeLog:
* module.cc (enum module_directness): Fix inconsistent
capitalisation.
(module_state::read_imports): Reparent module locations newly
seen as direct via partition.
gcc/testsuite/ChangeLog:
* g++.dg/modules/part-11_a.C: New test.
* g++.dg/modules/part-11_b.C: New test.
* g++.dg/modules/part-11_c.C: New test.
* g++.dg/modules/part-11_d.C: New test.
* g++.dg/modules/part-11_e.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
More information about the Gcc-bugs
mailing list