KhronosGroup / KhronosGroup/OpenCL-ICD-Loader
add -Wcast-qual to CI builds
- Dominant language
- C
- Stars
- 304
- Forks
- 171
- Avg merge
- 11h 30m
- Merged PRs (30d)
- 1
Description
We should add -Wcast-qual to our CI builds to catch casting problems in the future.
_Originally posted by @haonanya in https://github.com/KhronosGroup/OpenCL-ICD-Loader/issues/241#issuecomment-2372736110_:
> 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
Contributor guide
No contributing guide indexed for this repository
Research direction
Locate the CI build definitions and the GCC command used for the OpenCL-ICD-Loader, then reproduce the reported build with -Werror -Wcast-qual. Update the CI configuration so the flag is enabled and confirm the build completes without cast-qual warnings, including the reported code path in loader/linux/icd_linux.c.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- ci-cd
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100