-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GCC -fanalyzer report error when compiling glad #466
Comments
I can't reproduce this error with a GCC 13.2.1. |
Thanks for checking, I can't either. Please re-open if you have something we can reproduce. |
apologies i forgot to mention: This is happening with GCC 14, |
I still cannot reproduce using Fedora 40 With gl.h from http://glad.sh/#api=gl%3Acore%3D4.3&generator=c&options=ALIAS%2CHEADER_ONLY%2CLOADER and the following glad.c:
And compiling with |
apologies again, the error is a warning by default. so enabling these switches it should generate an output like this one:
to be more explicit on my CLI gcc switches:
I am actually compiling adding a #pragma GCC diagnostic ignored "-Wanalyzer-use-of-uninitialized-value" |
Can you point us to the generated GLAD file? Using a Fedora, with the gl.c file generated using the link of yesterday I fail to get this error. |
OK! I think I understand. EDIT: Even with latest Glad 0.1, I can't reproduce the error message on GCC 14. |
I can't see the error in the code even with the diagnostics, is it the unsigned cast? But even if I can't reproduce it, definitely in favor of fixing such bugs. |
what i used is basically this pacakge:
p.s. This is the header of the /*
OpenGL loader generated by glad 0.1.36 on Sat Apr 13 13:38:08 2024.
Language/Generator: C/C++
Specification: gl
APIs: gl=4.3
Profile: core
Extensions:
Loader: True
Local files: True
Omit khrplatform: False
Reproducible: False
Commandline:
--profile="core" --api="gl=4.3" --generator="c" --spec="gl" --local-files --extensions=""
Online:
https://glad.dav1d.de/#profile=core&language=c&specification=gl&loader=on&api=gl%3D4.3
*/ |
@Raffaello can you try changing for (index = 0; index < (unsigned) num_exts_i; index++) into: for (index = 0; index < num_exts_i; index++) And see if the warning goes away? |
it doesn't fix it. However i have to apologies again as i misled you before: the correct set-up to reproduce the error is through MinGW (@lephilousophe ) compiling using MinGW with MSYS2 in windows and GCC 13.2.0 ucrt64 leads to that warning. Most likely it could be some defines that are not well in place with MinGW and glad, not really a code error. |
removing the cast to unsigned leads to having this error:
|
Thanks, didn't consider that, but it should get rid of the other warning, just both uses of the integer need to be consistent, either unsigned or signed then it should be resolved. |
Make types consistent as it troubles the GCC analyzer.
The PR #473 will fix this error although I suspect a bug in GCC analyzer. |
Fixed with the linked PR! |
file: glad.c
line: 210
error:
use of uninitialized value '*exts_i.20_2 + _4' [CWE-457] [-Werror=analyzer-use-of-uninitialized-value]
glad generated 4.3 core.
The text was updated successfully, but these errors were encountered: