Bug 292054 - devel/gdb: fix build with clang 21
Summary: devel/gdb: fix build with clang 21
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Luca Pizzamiglio
URL:
Keywords:
Depends on:
Blocks: 292067
  Show dependency treegraph
 
Reported: 2025-12-30 21:15 UTC by Dimitry Andric
Modified: 2026-01-14 19:03 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (pizzamig)


Attachments
devel/gdb: fix build with clang 21 (37.50 KB, patch)
2025-12-30 21:15 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer freebsd_triage 2025-12-30 21:15:15 UTC
Compiling devel/gdb with clang 21 results in errors similar to:

    /wrkdirs/usr/ports/devel/gdb/work-py311/gdb-15.1/gdb/../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
          |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /wrkdirs/usr/ports/devel/gdb/work-py311/gdb-15.1/gdb/../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;
          |                    ^
    /wrkdirs/usr/ports/devel/gdb/work-py311/gdb-15.1/gdb/ui-out.h:385:16: note: in instantiation of template class 'enum_flags<ui_out_flag>' requested here
      385 |   ui_out_flags m_flags;
          |                ^
    /wrkdirs/usr/ports/devel/gdb/work-py311/gdb-15.1/gdb/../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
          |                                                    ^

This is because enum-flags.h does some trickery with casting enum values
to -1 to determine whether the underlying type is signed or not, as part
of its custom template to determine the actual underlying type.

It only works because -Wenum-constexpr-conversion is suppressed for this
part, but newer versions of clang turn the warning into a hard error.

Upstream had https://sourceware.org/bugzilla/show_bug.cgi?id=31331 for
this problem. Pull in the patch for it, plus two prerequisites.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2025-12-30 21:15:35 UTC
Created attachment 266660 [details]
devel/gdb: fix build with clang 21
Comment 2 commit-hook freebsd_committer freebsd_triage 2026-01-14 19:02:34 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=ba93f97b60a17df89c7cce53200b53c9da0428f1

commit ba93f97b60a17df89c7cce53200b53c9da0428f1
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-12-30 21:13:17 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2026-01-14 19:01:02 +0000

    devel/gdb: fix build with clang 21

    Compiling devel/gdb with clang 21 results in errors similar to:

        /wrkdirs/usr/ports/devel/gdb/work-py311/gdb-15.1/gdb/../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
              |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        /wrkdirs/usr/ports/devel/gdb/work-py311/gdb-15.1/gdb/../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;
              |                    ^
        /wrkdirs/usr/ports/devel/gdb/work-py311/gdb-15.1/gdb/ui-out.h:385:16: note: in instantiation of template class 'enum_flags<ui_out_flag>' requested here
          385 |   ui_out_flags m_flags;
              |                ^
        /wrkdirs/usr/ports/devel/gdb/work-py311/gdb-15.1/gdb/../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
              |                                                    ^

    This is because enum-flags.h does some trickery with casting enum values
    to -1 to determine whether the underlying type is signed or not, as part
    of its custom template to determine the actual underlying type.

    It only works because -Wenum-constexpr-conversion is suppressed for this
    part, but newer versions of clang turn the warning into a hard error.

    Upstream had https://sourceware.org/bugzilla/show_bug.cgi?id=31331 for
    this problem. Pull in the patch for it, plus two prerequisites.

    PR:             292054
    Approved by:    maintainer timeout (2 weeks)
    MFH:            2026Q1

 ...atch-gdb-15-branchpoint-0753-gb050b744be4 (new) |  94 +++++
 ...atch-gdb-15-branchpoint-0754-gba96d2e697a (new) | 460 +++++++++++++++++++++
 ...atch-gdb-15-branchpoint-1903-g4a0b2cb7210 (new) | 317 ++++++++++++++
 3 files changed, 871 insertions(+)
Comment 3 commit-hook freebsd_committer freebsd_triage 2026-01-14 19:02:36 UTC
A commit in branch 2026Q1 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=26b978c64c9d32be6e74d02873e6c2a2d0cd6565

commit 26b978c64c9d32be6e74d02873e6c2a2d0cd6565
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-12-30 21:13:17 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2026-01-14 19:01:59 +0000

    devel/gdb: fix build with clang 21

    Compiling devel/gdb with clang 21 results in errors similar to:

        /wrkdirs/usr/ports/devel/gdb/work-py311/gdb-15.1/gdb/../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
              |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        /wrkdirs/usr/ports/devel/gdb/work-py311/gdb-15.1/gdb/../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;
              |                    ^
        /wrkdirs/usr/ports/devel/gdb/work-py311/gdb-15.1/gdb/ui-out.h:385:16: note: in instantiation of template class 'enum_flags<ui_out_flag>' requested here
          385 |   ui_out_flags m_flags;
              |                ^
        /wrkdirs/usr/ports/devel/gdb/work-py311/gdb-15.1/gdb/../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
              |                                                    ^

    This is because enum-flags.h does some trickery with casting enum values
    to -1 to determine whether the underlying type is signed or not, as part
    of its custom template to determine the actual underlying type.

    It only works because -Wenum-constexpr-conversion is suppressed for this
    part, but newer versions of clang turn the warning into a hard error.

    Upstream had https://sourceware.org/bugzilla/show_bug.cgi?id=31331 for
    this problem. Pull in the patch for it, plus two prerequisites.

    PR:             292054
    Approved by:    maintainer timeout (2 weeks)
    MFH:            2026Q1

    (cherry picked from commit ba93f97b60a17df89c7cce53200b53c9da0428f1)

 ...atch-gdb-15-branchpoint-0753-gb050b744be4 (new) |  94 +++++
 ...atch-gdb-15-branchpoint-0754-gba96d2e697a (new) | 460 +++++++++++++++++++++
 ...atch-gdb-15-branchpoint-1903-g4a0b2cb7210 (new) | 317 ++++++++++++++
 3 files changed, 871 insertions(+)