KhronosGroup / KhronosGroup/KTX-Software
Build failure using gcc 16.1.0
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 317
- Avg merge
- 20h 12m
- Merged PRs (30d)
- 3
Description
Bug in Gentoo: https://bugs.gentoo.org/975268
```
gcc --version
gcc (Gentoo 16.1.0 p1) 16.1.0
Copyright (C) 2026 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```
```
/tmp/KTX-Software-4.4.2.old/tools/ktx/command.h: In instantiation of 'void ktx::Reporter::fatal_usage(Args&& ...) [with Args = {const char (&)[26], const std::__cxx11::basic_string, std::allocator >&}]':
/tmp/KTX-Software-4.4.2.old/tools/ktx/command.h:233:31: required from here
233 | report.fatal_usage("Unsupported format: \"{}\".", formatStr);
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/KTX-Software-4.4.2.old/tools/ktx/command.h:122:19: error: call to consteval function 'fmt::v11::fstring, std::allocator >&>((* & std::forward((* & args#0))))' is not a constant expression
122 | fmt::print(std::cerr, std::forward(args)...);
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /tmp/KTX-Software-4.4.2.old/external/fmt/include/fmt/format.h:41,
from /tmp/KTX-Software-4.4.2.old/external/fmt/include/fmt/chrono.h:23,
from /tmp/KTX-Software-4.4.2.old/external/fmt/include/fmt/ostream.h:23,
from /tmp/KTX-Software-4.4.2.old/tools/ktx/utility.h:10,
from /tmp/KTX-Software-4.4.2.old/tools/ktx/command.h:12:
/tmp/KTX-Software-4.4.2.old/tools/ktx/command.h:122:19: in 'constexpr' expansion of 'fmt::v11::fstring, std::allocator >&>((* & std::forward((* & args#0))))'
/tmp/KTX-Software-4.4.2.old/external/fmt/include/fmt/base.h:2736:53: in 'constexpr' expansion of 'fmt::v11::basic_string_view(((const char*)s))'
2736 | if (FMT_USE_CONSTEVAL) parse_format_string(s, checker(s, arg_pack()));
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/KTX-Software-4.4.2.old/external/fmt/include/fmt/base.h:548:5: error: 'args#0' is not a constant expression
548 | while (*s++) ++len;
| ^~~~~
```
The following code no longer builds with GCC 16.1:
```cpp
template
inline void do_print(Arg&&...a )
{
fmt::print(std::cerr, std::forward(a)...);
}
```
It can be fixed with
```cpp
template
inline void do_print(fmt::format_string f, Arg&&...a )
{
fmt::print(std::cerr, f, std::forward(a)...);
}
```
This is however not sufficient and we get other fmt related failures in `formatOptionalFileOffset`, `DiffHexFixedWidth`.
I am not sure if this is a bug in KTX-Software, libfmt or gcc.
Replacing the bundled libfmt with system one 12.1.0 does not fix the issue.
Contributor guide
Research direction
Reproduce the GCC 16.1.0 failure from the report and inspect tools/ktx/command.h, especially do_print and the calls around formatOptionalFileOffset and DiffHexFixedWidth. Compare the bundled external/fmt usage with the reported format_string approach, then verify that the KTX tools build successfully with GCC 16.1.0 and that the reported fmt-related failures are resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100