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.
_______________________________________________ bugs mailing list [email protected] http://lists.rtems.org/mailman/listinfo/bugs
