https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95715
Bug ID: 95715 Summary: __atomic_fetch_add accepts nonsense arguments 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 and g++ happily compiles this nonsense: int i = 0; void* p = 0; int r = __atomic_fetch_add(&i, &p, __ATOMIC_SEQ_CST); What does it mean to add a void* to an int? Clang diagnoses it correctly: ae.cc:3:32: error: cannot initialize a parameter of type 'int' with an rvalue of type 'void **' int r = __atomic_fetch_add(&i, &p, __ATOMIC_SEQ_CST); ^~ 1 error generated. And EDG mentions an unsigned int but at least rejects it: "ae.cc", line 3: error: argument of type "void **" is incompatible with parameter of type "unsigned int" int r = __atomic_fetch_add(&i, &p, __ATOMIC_SEQ_CST); ^ 1 error detected in the compilation of "ae.cc".