https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69425
Bug ID: 69425 Summary: __atomic_load should diagnose const output parameter Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: eric at efcs dot ca Target Milestone: --- The __atomic_load builtin takes a pointer to an output parameter. Obviously the output parameter cannot point to a const object. Unfortunatly GCC doesn't diagnose this case at compile time and this makes it much harder for users to find their bug. The reproducer is contrived, but I ran into this while writing generic code. #include <assert.h> int main() { const int source = 4; const int dest = 0; __atomic_load(&source, &dest, __ATOMIC_RELAXED); // Should emit -Wdiscards-qualifiers assert(dest == 4); // FAILS! 'dest' is still 0. }