Package: cppcheck
Severity: wishlist
The article at [1] reports about an issue with the MIN and MAX macros
that cause double evaluation by default. I think the more general issue
is worth checking for, please add a check for double evaluation when
using macros. Here is a test case from [1], the warning should trigger
on the second use of the min macro but not the first.
#include stdio.h
#define min(a, b) ((a) (b)) ? (a) : (b)
int main() {
int a = 1, b = 2;
printf (%d\n, min (a, b));
printf (a=%d, b=%d\n\n, a, b);
printf (%d\n, min (a++, b++));
printf (a=%d, b=%d\n\n, a, b);
}
1. http://dustri.org/b/min-and-max-macro-considered-harmful.html
--
bye,
pabs
https://wiki.debian.org/PaulWise
signature.asc
Description: This is a digitally signed message part