Issue 240481
Summary [Clang] mode attribute drops const qualifier, allowing assignment to const objects
Labels clang
Assignees
Reporter metp
    Clang appears to discard the `const` qualifier when applying `__attribute__((mode(QI)))`, allowing compilation with an assignment to an object declared `const`.

```c
void f(const int x __attribute__((mode(QI)))) {
    x = 1;
}
```

gcc refuses this as expected:

```
<source>: In function 'f':
<source>:2:7: error: assignment of read-only parameter 'x'
    2 |     x = 1;
      |       ^
Compiler returned: 1
```
Comiler explorer: https://godbolt.org/z/dTvvEcPx9
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to