Bug 271045

Summary: devel/gdb: fix build with clang 16
Product: Ports & Packages Reporter: Dimitry Andric <dim>
Component: Individual Port(s)Assignee: Luca Pizzamiglio <pizzamig>
Status: Closed FIXED    
Severity: Affects Some People CC: emaste
Priority: --- Flags: bugzilla: maintainer-feedback? (pizzamig)
Version: Latest   
Hardware: Any   
OS: Any   
Bug Depends on:    
Bug Blocks: 271047    
Attachments:
Description Flags
devel/gdb: fix build with clang 16 none

Description Dimitry Andric freebsd_committer freebsd_triage 2023-04-24 15:29:43 UTC
Clang 16 has a new error about integer values being outside the valid
range for enum types, which shows up when building gdb:

  In file included from /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/x86-fbsd-nat.c:20:
  In file included from /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/defs.h:65:
  /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/../gdbsupport/enum-flags.h:95:52: error: integer value -1 is outside the valid range of values [0, 15] for this enumeration type [-Wenum-constexpr-conversion]
      integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
                                                     ^
  In file included from /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/x86-bsd-nat.c:20:
  In file included from /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/defs.h:65:
  /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/../gdbsupport/enum-flags.h:95:52: error: integer value -1 is outside the valid range of values [0, 15] for this enumeration type [-Wenum-constexpr-conversion]
      integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
                                                     ^
  In file included from /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/x86-nat.c:20:
  In file included from /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/defs.h:65:
  /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/../gdbsupport/enum-flags.h:95:52: error: integer value -1 is outside the valid range of values [0, 15] for this enumeration type [-Wenum-constexpr-conversion]
      integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
                                                     ^
  In file included from /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/windows-tdep.c:18:
  In file included from /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/defs.h:65:
  /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/../gdbsupport/enum-flags.h:95:52: error: integer value -1 is outside the valid range of values [0, 15] for this enumeration type [-Wenum-constexpr-conversion]
      integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
                                                     ^

Upstream already noticed this, and committed
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ae61525fcf4 as
a workaround, so add this as an additional patch, until gdb 13.2 is
released.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2023-04-24 15:30:41 UTC
Created attachment 241700 [details]
devel/gdb: fix build with clang 16
Comment 2 commit-hook freebsd_committer freebsd_triage 2023-05-07 18:40:13 UTC
A commit in branch main references this bug:

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

commit 9e765fe77dabf9e37b052510072b0f41a2ab3ae6
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-04-24 15:00:37 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-05-07 18:38:47 +0000

    devel/gdb: fix build with clang 16

    Clang 16 has a new error about integer values being outside the valid
    range for enum types, which shows up when building gdb:

      In file included from /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/x86-fbsd-nat.c:20:
      In file included from /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/defs.h:65:
      /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/../gdbsupport/enum-flags.h:95:52: error: integer value -1 is outside the valid range of values [0, 15] for this enumeration type [-Wenum-constexpr-conversion]
          integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
                                                         ^
      In file included from /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/x86-bsd-nat.c:20:
      In file included from /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/defs.h:65:
      /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/../gdbsupport/enum-flags.h:95:52: error: integer value -1 is outside the valid range of values [0, 15] for this enumeration type [-Wenum-constexpr-conversion]
          integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
                                                         ^
      In file included from /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/x86-nat.c:20:
      In file included from /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/defs.h:65:
      /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/../gdbsupport/enum-flags.h:95:52: error: integer value -1 is outside the valid range of values [0, 15] for this enumeration type [-Wenum-constexpr-conversion]
          integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
                                                         ^
      In file included from /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/windows-tdep.c:18:
      In file included from /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/defs.h:65:
      /wrkdirs/usr/ports/devel/gdb/work-py39/gdb-13.1/gdb/../gdbsupport/enum-flags.h:95:52: error: integer value -1 is outside the valid range of values [0, 15] for this enumeration type [-Wenum-constexpr-conversion]
          integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
                                                         ^

    Upstream already noticed this, and committed
    https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ae61525fcf4 as
    a workaround, so add this as an additional patch, until gdb 13.2 is
    released.

    PR:             271045
    Approved by:    maintainer timeout (2 weeks)
    MFH:            2023Q2

 devel/gdb/Makefile                       |   3 +-
 devel/gdb/files/commit-ae61525fcf4 (new) | 128 +++++++++++++++++++++++++++++++
 2 files changed, 130 insertions(+), 1 deletion(-)