[Bug c++/121238] New: `-fmodules` causes invalid runtime exceptions with `std::format`
rohan at rohanlean dot de
gcc-bugzilla@gcc.gnu.org
Thu Jul 24 21:32:04 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121238
Bug ID: 121238
Summary: `-fmodules` causes invalid runtime exceptions with
`std::format`
Product: gcc
Version: 15.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: rohan at rohanlean dot de
Target Milestone: ---
The following two files, compiled with `-std=c++23 -fmodules` give a runtime
exception, `format error: invalid width or precision in format-spec`:
```
//--- bug.cppm
module;
#include <format>
export module bug;
void bug(std::format_args);
//--- bug.cpp
#include <print>
import bug;
auto g(std::string_view fmt, std::format_args args) -> void
{
std::print("{}\n", std::vformat(fmt, args));
}
template<typename... Ts>
auto f(std::format_string<Ts...> fmt, Ts &&... xs) -> void
{
g(fmt.get(), std::make_format_args(xs...));
}
int main()
{
f("{:5.1f}", 3.14);
}
```
It took me a while to reduce to this, but the title and reproducer are probably
still far from the heart of problem; sorry about that.
More information about the Gcc-bugs
mailing list