public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102607] New: [modules] option -g results in undefined reference to `typeinfo for type`
@ 2021-10-05 14:43 johelegp at gmail dot com
2021-10-05 19:23 ` [Bug c++/102607] " johelegp at gmail dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: johelegp at gmail dot com @ 2021-10-05 14:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102607
Bug ID: 102607
Summary: [modules] option -g results in undefined reference to
`typeinfo for type`
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: link-failure
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
Target Milestone: ---
See https://godbolt.org/z/qP6EPWhEz.
mod.cpp:
```C++
export module mod;
export struct B {
virtual ~B() = default;
};
```
main.cpp:
```C++
import mod;
int main() {
struct D : B {};
(void)D{};
}
```
Commands:
```
g++ -std=c++23 -fmodules-ts -g -c mod.cpp
g++ -std=c++23 -fmodules-ts -g -c main.cpp
g++ mod.o main.o
```
Output:
```
/usr/bin/ld: main.o:(.data.rel.ro+0x8): undefined reference to `typeinfo for B'
/usr/bin/ld: main.o:(.data.rel.ro+0x30): undefined reference to `typeinfo for
B'
collect2: error: ld returned 1 exit status
```
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/102607] [modules] option -g results in undefined reference to `typeinfo for type`
2021-10-05 14:43 [Bug c++/102607] New: [modules] option -g results in undefined reference to `typeinfo for type` johelegp at gmail dot com
@ 2021-10-05 19:23 ` johelegp at gmail dot com
2024-01-23 9:46 ` cvs-commit at gcc dot gnu.org
2024-01-27 10:26 ` nshead at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: johelegp at gmail dot com @ 2021-10-05 19:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102607
--- Comment #1 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
A workaround is to define `B`'s destructor as
`constexpr virtual ~B() { }`.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/102607] [modules] option -g results in undefined reference to `typeinfo for type`
2021-10-05 14:43 [Bug c++/102607] New: [modules] option -g results in undefined reference to `typeinfo for type` johelegp at gmail dot com
2021-10-05 19:23 ` [Bug c++/102607] " johelegp at gmail dot com
@ 2024-01-23 9:46 ` cvs-commit at gcc dot gnu.org
2024-01-27 10:26 ` nshead at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-23 9:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102607
--- 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:affef534b0335592336c82918f15242576e2ab8f
commit r14-8350-gaffef534b0335592336c82918f15242576e2ab8f
Author: Nathaniel Shead <nathanieloshead@gmail.com>
Date: Wed Jan 17 16:50:39 2024 +1100
c++: Fix handling of extern templates in modules [PR112820]
Currently, extern templates are detected by looking for the
DECL_EXTERNAL flag on a TYPE_DECL. However, this is incorrect:
TYPE_DECLs don't actually set this flag, and it happens to work by
coincidence due to TYPE_DECL_SUPPRESS_DEBUG happening to use the same
underlying bit. This however causes issues with other TYPE_DECLs that
also happen to have suppressed debug information.
Instead, this patch reworks the logic so CLASSTYPE_INTERFACE_ONLY is
always emitted into the module BMI and can then be used to check for an
extern template correctly.
Otherwise, for other declarations we always want to redetermine this:
even for declarations from the GMF, we may change our mind on whether to
import or export depending on decisions made later in the TU after
importing so we shouldn't decide this now, or necessarily reuse what the
module we'd imported had decided.
Some of this may need to change in the future to account for
https://github.com/itanium-cxx-abi/cxx-abi/issues/170.
PR c++/112820
PR c++/102607
gcc/cp/ChangeLog:
* module.cc (trees_out::lang_type_bools): Write interface_only
and interface_unknown.
(trees_in::lang_type_bools): Read the above flags.
(trees_in::decl_value): Reset CLASSTYPE_INTERFACE_* except for
extern templates.
(trees_in::read_class_def): Remove buggy extern template
handling.
gcc/testsuite/ChangeLog:
* g++.dg/modules/debug-2_a.C: New test.
* g++.dg/modules/debug-2_b.C: New test.
* g++.dg/modules/debug-2_c.C: New test.
* g++.dg/modules/debug-3_a.C: New test.
* g++.dg/modules/debug-3_b.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/102607] [modules] option -g results in undefined reference to `typeinfo for type`
2021-10-05 14:43 [Bug c++/102607] New: [modules] option -g results in undefined reference to `typeinfo for type` johelegp at gmail dot com
2021-10-05 19:23 ` [Bug c++/102607] " johelegp at gmail dot com
2024-01-23 9:46 ` cvs-commit at gcc dot gnu.org
@ 2024-01-27 10:26 ` nshead at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-01-27 10:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102607
Nathaniel Shead <nshead at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
CC| |nshead at gcc dot gnu.org
Target Milestone|--- |14.0
Status|UNCONFIRMED |RESOLVED
Assignee|unassigned at gcc dot gnu.org |nshead at gcc dot gnu.org
--- Comment #3 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Fixed for GCC 14.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-01-27 10:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05 14:43 [Bug c++/102607] New: [modules] option -g results in undefined reference to `typeinfo for type` johelegp at gmail dot com
2021-10-05 19:23 ` [Bug c++/102607] " johelegp at gmail dot com
2024-01-23 9:46 ` cvs-commit at gcc dot gnu.org
2024-01-27 10:26 ` nshead at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).