Bug 504247

Summary: Error: variable template 'format_kind' declared with deduced type 'const auto' cannot appear in its own initializer when building with Clang
Product: [Frameworks and Libraries] frameworks-kwallet Reporter: Marcus Seyfarth <m.seyfarth>
Component: generalAssignee: Valentin Rusu <valir>
Status: RESOLVED UPSTREAM    
Severity: normal CC: kdelibs-bugs-null, nate
Priority: NOR    
Version First Reported In: 6.14.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Marcus Seyfarth 2025-05-15 06:46:53 UTC
SUMMARY
Compiling kwallet 6.14 with Clang-21git (05f1e313948768fdd8527969cd79809cbd0654ff) on CachyOS, I get this compilation error:

In file included from /tmp/makepkg/kwallet/src/kwallet-6.14.0/src/runtime/kwalletbackend/cbc.cc:9:
In file included from /tmp/makepkg/kwallet/src/build/src/runtime/kwalletbackend/kwalletbackend_debug.h:6:
In file included from /usr/include/qt6/QtCore/QLoggingCategory:1:
In file included from /usr/include/qt6/QtCore/qloggingcategory.h:8:
In file included from /usr/include/qt6/QtCore/qdebug.h:14:
In file included from /usr/include/qt6/QtCore/qfloat16.h:14:
In file included from /usr/include/qt6/QtCore/qtformat_impl.h:19:
/usr/lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/format:5118:7: error: variable template 'format_kind' declared with deduced type 'const auto' cannot appear in its own initializer
 5118 |       format_kind<_Rg> // you can specialize this for non-const input ranges
      |       ^


STEPS TO REPRODUCE
1.  Get Clang-21git (05f1e313948768fdd8527969cd79809cbd0654ff) 
2. Try to compile kwallet
3. The build will error out around [ 20%] Building CXX object src/api/KWallet/CMakeFiles/KF6Wallet.dir/KF6Wallet_autogen/mocs_compilation.cpp.o

OBSERVED RESULT
Build failure.

EXPECTED RESULT
Build success.

SOFTWARE/OS VERSIONS
Windows: -
macOS: -
Linux/KDE Plasma: 
KDE Plasma Version: 6.3.5
KDE Frameworks Version: 6.14.0
Qt Version: 6.9.0

ADDITIONAL INFORMATION
CachyOS is on GCC 15.1.1

The build succeeds when using GCC to build the package.
Comment 1 Marcus Seyfarth 2025-05-15 14:46:49 UTC
This GCC bug report seems related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120190

See also: https://gcc.gnu.org/pipermail/gcc-patches/2025-May/683760.html
Comment 2 Marcus Seyfarth 2025-05-15 14:51:27 UTC
The GCC bug report also linked to a relevant Clang change that might be what I need and was only pushed yesterday: https://github.com/llvm/llvm-project/commit/86ba681e286d0a377830d2cbbc5e58bb5fad442c
Comment 3 Nate Graham 2025-05-15 17:28:40 UTC
I gather this worked in Frameworks 6.13?

Can you confirm that clang change fixes it?
Comment 4 Marcus Seyfarth 2025-05-15 20:02:07 UTC
(In reply to Nate Graham from comment #3)
> I gather this worked in Frameworks 6.13?
> 
> Can you confirm that clang change fixes it?

Some other KDE packages are also affected by the same error that used to compile fine with Clang. I cannot tell if this is a regression from the KDE side, but it looks to be a regression from the toolchain-side to me (but I am not a programmer).

a) A GCC fix landed today in master for this issue (r16-658-gc65725eccbabf3b9b5965f27fff2d3b9f6c75930) which is marked to need a backport for 15.2.

b) From the Clang committ message, I gathered that this started to regress with Clang-git on May 8th. My current Clang-git build that shows this issue with Kwallet is from May 10th and the fix landed on May 14th. I'll try to verify this with a new Clang-git build on the weekend and will report back here.
Comment 5 Nate Graham 2025-05-16 14:26:28 UTC
Thanks! It does look like a toolchain regression to me.
Comment 6 Marcus Seyfarth 2025-05-29 10:16:38 UTC
Indeed, I've now tested a newer Clang-21 revision that compiles kwallet just fine. Closing as Resolved Upstream.