RTEMS | libdebugger/rtems-debugger-*.c: Address ignored qualifier warnings (!803)

Chris Johns (@chris) gitlab at rtems.org
Sun Oct 19 23:28:16 UTC 2025




Chris Johns commented on a discussion on cpukit/libdebugger/rtems-debugger-aarch64.c: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/803#note_135180

 >    memcpy( &thread->registers[ offset ], &value, sizeof( uint64_t ) );
 >  }
 >  
 > -static const uint64_t rtems_debugger_get_int_reg(
 > +static uint64_t rtems_debugger_get_int_reg(

I had a play with some code and no warning flags:

```c
#include <stdio.h>

int foo(int a, int b) {
  a += b;
  return a;
}

const int const_foo(const int a, const int b) {
  // a += b;
  //
  // Cannot do as above. clang for FreeBSD 14 gives:
  //  test-ret-const.c:11:5: error: cannot assign to variable 'a' with const-qualified type 'const int'
  //     11 |   a += b;
  //        |   ~ ^
  return a + b;
}

int main(int argc, char** arg) {
  int c = foo(1, 3);
  int d = foo(4, 6);
  printf("c = %i, d = %i\n", c, d);
  return 0;
}
```

The code also compiles as C++ (I copied to a `.cc` file) without error. The warnings are the same with `-Wall -Wextra` for C and C++. As the GCC manual says the return type is not an lvalue. The piece of code does highlight (in comments) how `const` arguments do matter.

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/803#note_135180
You're receiving this email because of your account on gitlab.rtems.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20251019/fd743a29/attachment.htm>


More information about the bugs mailing list