Skip to content

gdb/amd-dbgapi: fix -Wdeprecated-enum-enum-conversion warning#109

Open
simark wants to merge 1 commit intoROCm:amd-stagingfrom
simark:users/smarchi/fix-deprecated-enum-enum-conversion
Open

gdb/amd-dbgapi: fix -Wdeprecated-enum-enum-conversion warning#109
simark wants to merge 1 commit intoROCm:amd-stagingfrom
simark:users/smarchi/fix-deprecated-enum-enum-conversion

Conversation

@simark
Copy link
Copy Markdown
Contributor

@simark simark commented May 4, 2026

With gcc 16, I get:

/home/smarchi/src/binutils-gdb/gdb/amd-dbgapi-target.c: In function ‘void info_dispatches_command(const char*, int)’:
/home/smarchi/src/binutils-gdb/gdb/amd-dbgapi-target.c:4729:26: error: bitwise operation between different enumeration types ‘amd_dbgapi_dispatch_barrier_t’ and ‘amd_dbgapi_dispatch_fence_scope_t’ is deprecated [-Werror=deprecated-enum-enum-conversion]
 4729 |             if ((barrier | acquire) && release)
      |                  ~~~~~~~~^~~~~~~~~

IIUC, the intent of this is just to know if we've written something in ss already, and if we're going to write more. And if so, write a | separator. The | should probably have been a ||, or because we like to be explicit in GDB:

if ((barrier != AMD_DBGAPI_DISPATCH_BARRIER_NONE
     || acquire != AMD_DBGAPI_DISPATCH_FENCE_SCOPE_NONE)
    && release != AMD_DBGAPI_DISPATCH_FENCE_SCOPE_NONE)
  ss << "|";

But I think it's simpler to rewrite this to append to a string, and append a | if we're about to append something and the string is not empty. A stringstream has no advantage over using a string in this case.

Change-Id: I48307186f00a9943f6be388960c85ce53d10b0c3

Motivation

Technical Details

Test Plan

Test Result

Submission Checklist

@simark simark requested a review from a team as a code owner May 4, 2026 19:36
With gcc 16, I get:

    /home/smarchi/src/binutils-gdb/gdb/amd-dbgapi-target.c: In function ‘void info_dispatches_command(const char*, int)’:
    /home/smarchi/src/binutils-gdb/gdb/amd-dbgapi-target.c:4729:26: error: bitwise operation between different enumeration types ‘amd_dbgapi_dispatch_barrier_t’ and ‘amd_dbgapi_dispatch_fence_scope_t’ is deprecated [-Werror=deprecated-enum-enum-conversion]
     4729 |             if ((barrier | acquire) && release)
          |                  ~~~~~~~~^~~~~~~~~

IIUC, the intent of this is just to know if we've written something in `ss`
already, and if we're going to write more.  And if so, write a `|`
separator.  The `|` should probably have been a `||`, or because we like
to be explicit in GDB:

    if ((barrier != AMD_DBGAPI_DISPATCH_BARRIER_NONE
         || acquire != AMD_DBGAPI_DISPATCH_FENCE_SCOPE_NONE)
        && release != AMD_DBGAPI_DISPATCH_FENCE_SCOPE_NONE)
      ss << "|";

But I think it's simpler to rewrite this to append to a string, and
append a `|` if we're about to append something and the string is not
empty.  A stringstream has no advantage over using a string in this
case.

Change-Id: I48307186f00a9943f6be388960c85ce53d10b0c3
@simark simark force-pushed the users/smarchi/fix-deprecated-enum-enum-conversion branch from 4e81b2f to 6561727 Compare May 4, 2026 19:36
Copy link
Copy Markdown
Collaborator

@lumachad lumachad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK to me. I think the readability took a hit here, but I don't feel strongly about it if it works.

Copy link
Copy Markdown
Collaborator

@lancesix lancesix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

I think this makes things cleaner as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants