public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109946] New: linker error undefined reference to `vtable for std::bad_expected_access<void>'
@ 2023-05-23 14:47 saifi.khan at nishan dot io
2024-03-11 22:12 ` [Bug c++/109946] [c++modules] " ppalka at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: saifi.khan at nishan dot io @ 2023-05-23 14:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109946
Bug ID: 109946
Summary: linker error undefined reference to `vtable for
std::bad_expected_access<void>'
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: saifi.khan at nishan dot io
Target Milestone: ---
Environment: Archlinux kernel 6.3.2 glibc 2.37 gcc 13.1 gcc 14.0.0
Consider the following code
import "iostream";
import "string";
import "string_view";
import "expected";
import "charconv";
import "system_error";
namespace parser {
enum class error {
input_invalid
, overflow
};
auto logic (std::string_view str) -> std::expected <double, error> {
int value {0};
std::from_chars_result result { std::from_chars (str.begin (), str.end
(), value) };
if (result.ec == std::errc{}) {
return value;
}
else if (result.ec == std::errc::invalid_argument) {
return std::unexpected {error::input_invalid};
}
else if (result.ec == std::errc::result_out_of_range) {
return std::unexpected {error::overflow};
}
}
}
auto test () -> void {
std::string str { "9876dairy" };
const auto result { parser::logic (str) };
if (result.has_value ()) {
std::cout << result.value ()
<< '\n';
}
else if (result.error () == parser::error::input_invalid) {
std::cout << "E: input invalid"
<< '\n';
}
else if (result.error () == parser::error::overflow) {
std::cout << "overflow"
<< '\n';
}
else {
std::cout << "unexpected"
<< '\n';
}
}
The code compiles and program work fine with
- gcc 13.1.1
- gcc 14.0.0
as long as i don't use the option -fmodules-ts.
When using the -fmodules-ts flag, the following linker error is seen:
/usr/bin/ld: /tmp/cchUGnbx.o: warning: relocation against
`_ZTVSt19bad_expected_accessIvE' in read-only section
`.text._ZNSt19bad_expected_accessIvED2Ev[_ZNSt19bad_expected_accessIvED5Ev]'
/usr/bin/ld: /tmp/cchUGnbx.o: in function
`std::bad_expected_access<void>::bad_expected_access()':
/opt/gcc/include/c++/14.0.0/expected:80: undefined reference to `vtable for
std::bad_expected_access<void>'
/usr/bin/ld: /tmp/cchUGnbx.o: in function
`std::bad_expected_access<void>::~bad_expected_access()':
/opt/gcc/include/c++/14.0.0/expected:85: undefined reference to `vtable for
std::bad_expected_access<void>'
/usr/bin/ld:
/tmp/cchUGnbx.o:(.data.rel.ro._ZTISt19bad_expected_accessIN6parser5errorEE[_ZTISt19bad_expected_accessIN6parser5errorEE]+0x10):
undefined reference to `typeinfo for std::bad_expected_access<void>'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/109946] [c++modules] linker error undefined reference to `vtable for std::bad_expected_access<void>'
2023-05-23 14:47 [Bug c++/109946] New: linker error undefined reference to `vtable for std::bad_expected_access<void>' saifi.khan at nishan dot io
@ 2024-03-11 22:12 ` ppalka at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-03-11 22:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109946
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Target Milestone|--- |14.0
CC| |ppalka at gcc dot gnu.org
Status|UNCONFIRMED |RESOLVED
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
This seems to work with recent GCC trunk.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-03-11 22:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-23 14:47 [Bug c++/109946] New: linker error undefined reference to `vtable for std::bad_expected_access<void>' saifi.khan at nishan dot io
2024-03-11 22:12 ` [Bug c++/109946] [c++modules] " ppalka 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).