Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 954752 - dev-debug/gdb-15.2 fails to build with clang: non-type template argument is not a constant expression
Summary: dev-debug/gdb-15.2 fails to build with clang: non-type template argument is n...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Toolchain Maintainers
URL: https://sourceware.org/git/gitweb.cgi...
Whiteboard:
Keywords: PATCH
Depends on:
Blocks: systemwide-clang
  Show dependency tree
 
Reported: 2025-04-26 10:52 UTC by Jannik Glückert
Modified: 2025-04-26 11:08 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jannik Glückert 2025-04-26 10:52:19 UTC
building gdb 15 with clang 20 produces the following error:

./../gdbsupport/enum-flags.h:97:34: error: non-type template argument is not a constant expression
   97 |     integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./../gdbsupport/enum-flags.h:134:20: note: in instantiation of template class 'enum_underlying_type<ui_out_flag>' requested here
  134 |   typedef typename enum_underlying_type<enum_type>::type underlying_type;
      |                    ^
././ui-out.h:385:16: note: in instantiation of template class 'enum_flags<ui_out_flag>' requested here
  385 |   ui_out_flags m_flags;
      |                ^
./../gdbsupport/enum-flags.h:97:52: note: integer value -1 is outside the valid range of values [0, 15] for the enumeration type 'ui_out_flag'
   97 |     integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
      |                                                    ^
./../gdbsupport/enum-flags.h:97:34: error: non-type template argument is not a constant expression
   97 |     integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./../gdbsupport/enum-flags.h:134:20: note: in instantiation of template class 'enum_underlying_type<domain_search_flag>' requested here
  134 |   typedef typename enum_underlying_type<enum_type>::type underlying_type;
      |                    ^
./symtab.h:920:31: note: in instantiation of template class 'enum_flags<domain_search_flag>' requested here
  920 | constexpr domain_search_flags SEARCH_ALL_DOMAINS
      |                               ^
./../gdbsupport/enum-flags.h:97:52: note: integer value -1 is outside the valid range of values [0, 255] for the enumeration type 'domain_search_flag'
   97 |     integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
      |                                                    ^

this is because gdb is attempting to instantiate an unsigned enum from a signed, negative value, which is UB. Clang previously tolerated this in constexpr contexts (and gdb just silenced the warning with a pragma), but as of clang++20 this appears to be enforced.

fixed upstream in https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4a0b2cb7210c65c8c9f4a56345749bb7294fbfbf

If I'm seeing correctly, the fix also made it into gdb 16