#778659 cppcheck: check for double evaluation when using macros

Package:
cppcheck
Source:
cppcheck
Description:
tool for static C/C++ code analysis (CLI)
Submitter:
Paul Wise
Date:
2021-09-22 04:42:12 UTC
Severity:
wishlist
Tags:
#778659#5
Date:
2015-02-18 01:32:16 UTC
From:
To:
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

#778659#10
Date:
2015-09-08 18:45:36 UTC
From:
To:
forwarded 778659 http://trac.cppcheck.net/ticket/6984
thanks

#778659#23
Date:
2021-09-22 04:23:55 UTC
From:
To:
Hello,

Good morning,

We have gone through your samples from a partner and Here is our  Order
List. Please do bear in mind that we are very much in  need of this
order, quote your competitive prices.

Kindly send the Order confirmation.

Your early reply will be much appreciated.

Best Regards,

Maryanah Erwin.

PT FINDORA INTERNUSA

Jln Pahlawan 66 Kec. Arjawinangun

45162 CIREBON West-Java INDONESIA

tel : +62 231 357334

fax: +62 231 357260

email: marketing@findora.com