Skip to content
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

add -Wcast-qual to CI builds #242

Open
bashbaug opened this issue Sep 26, 2024 · 0 comments
Open

add -Wcast-qual to CI builds #242

bashbaug opened this issue Sep 26, 2024 · 0 comments

Comments

@bashbaug
Copy link
Contributor

We should add -Wcast-qual to our CI builds to catch casting problems in the future.

Originally posted by @haonanya in #241 (comment):

Which compiler / compiler flags did you use to find these issues? Is this something we could have caught via CI?

gcc uses -Werror -Wcast-qual build fail:

[haonanya]$ /usr/bin/gcc -DCL_ENABLE_LAYERS -DCL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES -DCL_TARGET_OPENCL_VERSION=300 -DOPENCL_ICD_LOADER_VERSION_MAJOR=3 -DOPENCL_ICD_LOADER_VERSION_MINOR=0 -DOPENCL_ICD_LOADER_VERSION_REV=6 -DOpenCL_EXPORTS -I/export/users/haonanya/OpenCL-CTS/OpenCL-Headers -I/export/users/haonanya/OpenCL-CTS/OpenCL-ICD-Loader/build -I/export/users/haonanya/OpenCL-CTS/OpenCL-ICD-Loader/loader -fPIC -std=gnu99 -Werror -Wcast-qual -MD -MT CMakeFiles/OpenCL.dir/loader/linux/icd_linux.c.o -MF CMakeFiles/OpenCL.dir/loader/linux/icd_linux.c.o.d -o CMakeFiles/OpenCL.dir/loader/linux/icd_linux.c.o -c /export/users/haonanya/OpenCL-CTS/OpenCL-ICD-Loader/loader/linux/icd_linux.c
/export/users/haonanya/OpenCL-CTS/OpenCL-ICD-Loader/loader/linux/icd_linux.c: In function ‘compareDirElem’:
/export/users/haonanya/OpenCL-CTS/OpenCL-ICD-Loader/loader/linux/icd_linux.c:132:21: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual]
132 | return strcoll(((struct dirElem *)a)->d_name, ((struct dirElem *)b)->d_name);
| ^
/export/users/haonanya/OpenCL-CTS/OpenCL-ICD-Loader/loader/linux/icd_linux.c:132:52: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual]
132 | return strcoll(((struct dirElem *)a)->d_name, ((struct dirElem *)b)->d_name);
| ^
cc1: all warnings being treated as errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant