[Bug other/83048] New: wrap multi-statement macros in do {} while (0)
vries at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Nov 19 13:21:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83048
Bug ID: 83048
Summary: wrap multi-statement macros in do {} while (0)
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
Assignee: unassigned at gcc dot gnu.org
Reporter: vries at gcc dot gnu.org
Target Milestone: ---
This command:
...
$ rm -f OUTPUT; for f in $(find . -type f | egrep -v '\.git|/testsuite/'); do
echo $f; ( perl -p -e 's/\\\n//' $f| egrep "^#define.*;.*;$"| egrep -v
'case|break'); done | grep -B1 'define' > OUTPUT
...
finds some candidates for fixing, f.i. in libobjc/class.c:
...
#define CLASS_TABLE_HASH(INDEX, HASH, CLASS_NAME) \
HASH = 0; \
for (INDEX = 0; CLASS_NAME[INDEX] != '\0'; INDEX++) \
{ \
HASH = (HASH << 4) ^ (HASH >> 28) ^ CLASS_NAME[INDEX]; \
} \
\
HASH = (HASH ^ (HASH >> 10) ^ (HASH >> 20)) & CLASS_TABLE_MASK;
...
More information about the Gcc-bugs
mailing list