glew icon indicating copy to clipboard operation
glew copied to clipboard

Various compiler warnings

Open FrostKiwi opened this issue 1 year ago • 3 comments

As advised by https://github.com/nigels-com/glew/issues/325#issuecomment-1240320270, I'm sharing compiler warnings, which are given by gcc for the GLEW 2.2.0 release, when compiling from source statically with GLEW_STATIC defined. Here is the the relevant section from my Makefile's output

-- compiling src/glew.c --
cc -c src/glew.c -o obj/glew.o -I inc -pipe -static -Ofast -s -flto=8 -Wall -DGLEW_STATIC
src/glew.c: In function '_glewStrSame1':
src/glew.c:256:29: warning: the comparison will always evaluate as 'true' for the pointer operand in '*a + (sizetype)i' must not be NULL [-Waddress]
  256 |     while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++;
      |                             ^~
src/glew.c:256:44: warning: the comparison will always evaluate as 'true' for the pointer operand in 'b + (sizetype)i' must not be NULL [-Waddress]
  256 |     while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++;
      |                                            ^~
src/glew.c: In function '_glewStrSame2':
src/glew.c:272:29: warning: the comparison will always evaluate as 'true' for the pointer operand in '*a + (sizetype)i' must not be NULL [-Waddress]
  272 |     while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++;
      |                             ^~
src/glew.c:272:44: warning: the comparison will always evaluate as 'true' for the pointer operand in 'b + (sizetype)i' must not be NULL [-Waddress]
  272 |     while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++;
      |                                            ^~
src/glew.c: In function '_glewStrSame3':
src/glew.c:288:29: warning: the comparison will always evaluate as 'true' for the pointer operand in '*a + (sizetype)i' must not be NULL [-Waddress]
  288 |     while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++;
      |                             ^~
src/glew.c:288:44: warning: the comparison will always evaluate as 'true' for the pointer operand in 'b + (sizetype)i' must not be NULL [-Waddress]
  288 |     while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++;
      |                                            ^~

FrostKiwi avatar Sep 08 '22 08:09 FrostKiwi

Could you mention gcc version.

nigels-com avatar Sep 08 '22 10:09 nigels-com

Could you mention gcc version.

GCC 12.2.0 (Rev1, Built by MSYS2 project) 12.2.0 as installed by the package mingw64/mingw-w64-x86_64-gcc in MSYS2 and it's MinGW64 environment.

FrostKiwi avatar Sep 08 '22 11:09 FrostKiwi

I can confirm these warnings for the 2.2.0 release in Ubuntu 22.04 (Jammy) using gcc-12 toolchain. gcc-10 and gcc-11 both compile without complaint.

For current master branch, gcc-12 also builds without complaint. So this issue will be resolved in the next release, without any further action needed.

nigels-com avatar Sep 09 '22 12:09 nigels-com