The analyzer has detected a function annotated as pure, but it is not.
You can annotate functions in the following ways:
A function is pure if it meets the following requirements:
Here are the most common cases in which a function purity is violated:
Take a look at the following example of an impure function annotated as pure:
[[gnu::pure]] void foo()
{
int *x = new int;
....
}
The 'foo' function is annotated in the code using the 'gnu::pure' attribute but allocates dynamic memory and violates the "no side effects" requirement.
To fix this, either remove the 'pure' attribute or modify the function as follows:
[[gnu::pure]] void foo()
{
int x;
....
}
Was this page helpful?
Your message has been sent. We will email you at
If you do not see the email in your inbox, please check if it is filtered to one of the following folders:
Take
a chance!