https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95378
Bug ID: 95378 Summary: __atomic_load will write to objects of cv-qualified types Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: accepts-invalid Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- GCC happily compiles this: void f() { int i = 1; const int c = 0; __atomic_load(&i, &c, __ATOMIC_SEQ_CST); volatile int v = 0; __atomic_load(&i, &v, __ATOMIC_SEQ_CST); const volatile int cv = 0; __atomic_load(&i, &cv, __ATOMIC_SEQ_CST); } Clang sensibly rejects it: af.cc:5:21: error: cannot initialize a parameter of type 'int *' with an rvalue of type 'const int *' __atomic_load(&i, &c, __ATOMIC_SEQ_CST); ^~ af.cc:7:21: error: cannot initialize a parameter of type 'int *' with an rvalue of type 'volatile int *' __atomic_load(&i, &v, __ATOMIC_SEQ_CST); ^~ af.cc:9:21: error: cannot initialize a parameter of type 'int *' with an rvalue of type 'const volatile int *' __atomic_load(&i, &cv, __ATOMIC_SEQ_CST); ^~~