https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64720

            Bug ID: 64720
           Summary: Provide strict check for pure attribute
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fizzbooze at gmail dot com

Currently an impure function can be attributed as 'pure' and still compile
correctly with no warnings or errors. i.e.:

// BEGIN CODE
int global = 0;

__attribute__((pure))
void foo() {
    global += 1; // this obviously violates the pure attribute
}

int main() {
    foo();
}
// END CODE

It would be nice to be able to enable some sort of warning or error for code
like this.

Reply via email to