Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove const for ScopeGuard operator #156

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

trixirt
Copy link
Contributor

@trixirt trixirt commented Jan 30, 2024

With gcc 14 on Fedora rawhide, there is this build error

[ 3%] Building CXX object rocm_smi/CMakeFiles/rocm_smi64.dir/__/src/rocm_smi_device.cc.o In file included from rocm_smi_lib/src/rocm_smi_device.cc:67: rocm_smi_lib/include/rocm_smi/rocm_smi_utils.h: In member function ‘amd::smi::ScopeGuard& amd::smi::ScopeGuard::operator=(const amd::smi::ScopeGuard&)’: /home/trix/rocm/rocm_smi_lib/include/rocm_smi/rocm_smi_utils.h:222:18: error: assignment of member ‘dismiss_’ in read-only object
222 | rhs.dismiss_ = true;
| ~~~~~~~~~~~~~^~~~~~

The rhs parameter can not be const and setting a sideeffect. So remove const

With gcc 14 on Fedora rawhide, there is this build error

[  3%] Building CXX object rocm_smi/CMakeFiles/rocm_smi64.dir/__/src/rocm_smi_device.cc.o
In file included from rocm_smi_lib/src/rocm_smi_device.cc:67:
rocm_smi_lib/include/rocm_smi/rocm_smi_utils.h: In member function ‘amd::smi::ScopeGuard<lambda>& amd::smi::ScopeGuard<lambda>::operator=(const amd::smi::ScopeGuard<lambda>&)’:
/home/trix/rocm/rocm_smi_lib/include/rocm_smi/rocm_smi_utils.h:222:18: error: assignment of member ‘dismiss_’ in read-only object
  222 |     rhs.dismiss_ = true;
      |     ~~~~~~~~~~~~~^~~~~~

The rhs parameter can not be const and setting a sideeffect.
So remove const

Signed-off-by: Tom Rix <trix@redhat.com>
@AngryLoki
Copy link

AngryLoki commented May 10, 2024

@cfreehill , could you check this? rocm_smi_lib fails to compile with clang-19 too.

/var/tmp/portage/dev-util/rocm-smi-6.1.1/work/rocm_smi_lib-rocm-6.1.1/include/rocm_smi/rocm_smi_utils.h:237:18: error: cannot assign to variable 'rhs' with const-qualified type 'const ScopeGuard<lambda> &'
  237 |     rhs.dismiss_ = true;
      |     ~~~~~~~~~~~~ ^

Original commit was 8e03d10

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.

None yet

2 participants