Bug#778659: cppcheck: check for double evaluation when using macros

2015-09-08 Thread Joachim Reichel
forwarded 778659 http://trac.cppcheck.net/ticket/6984
thanks



Bug#778659: cppcheck: check for double evaluation when using macros

2015-02-17 Thread Paul Wise
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