error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
yesudeep opened this issue · comments
Yesudeep Mangalapilly commented
GCC complains about this when the "-Werror=pointer-arith" flag is turned on
and one uses EXPECT_EQ
to compare pointers:
external/com_github_sheredom_utest/utest.h:528:36: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
528 | #define UTEST_AUTO(x) __typeof__(x + 0)
| ^
external/com_github_sheredom_utest/utest.h:580:5: note: in expansion of macro 'UTEST_AUTO'
580 | UTEST_AUTO(y) yEval = (y); \
| ^~~~~~~~~~
external/com_github_sheredom_utest/utest.h:633:25: note: in expansion of macro 'UTEST_EXPECT'
633 | #define EXPECT_EQ(x, y) UTEST_EXPECT(x, y, ==)
| ^~~~~~~~~~~~
foo/foo_test.c:42:3: note: in expansion of macro 'EXPECT_EQ'
42 | EXPECT_EQ(p, NULL);
GCC version:
>> gcc --version
gcc (Clear Linux OS for Intel Architecture) 12.1.1 20220720 releases/gcc-12.1.0-247-g94d44a83ff
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
OS:
>> uname -mrs
Linux 5.18.12-1160.native x86_64
I can work around this by using EXPECT_TRUE
to make pointer comparisons, but wonder whether there is a fix for this.
Neil Henning commented
I can't see a way around this one sadly.