Bug 36147
| Summary: | const function pointer leads to: warning: function called through a non-compatible type | ||
|---|---|---|---|
| Product: | Sisyphus | Reporter: | Ivan Zakharyaschev <imz> |
| Component: | gcc15 | Assignee: | Gleb F-Malinovskiy <glebfm> |
| Status: | NEW --- | QA Contact: | qa-sisyphus |
| Severity: | minor | ||
| Priority: | P3 | CC: | glebfm, iv, kotopesutility, vseleznv |
| Version: | unstable | ||
| Hardware: | all | ||
| OS: | Linux | ||
gcc8 удалён из Сизифа (задание 329097). Воспроизводится на gcc 15.3.1 (15.3.1-alt1) с -O2 -Wall на минимальном примере:
typedef int (*HGE_t)(void *h, int tag, int *type, void **p, int *c);
int headerGetEntryMinMemory(void *h, int tag, unsigned *type, void **p, int *c);
int f(void *h, void **p) {
const HGE_t hge = (HGE_t)headerGetEntryMinMemory;
int c;
return hge(h, 1, (int*)0, p, &c);
}
t.c:6:12: warning: function called through a non-compatible type
Без -O предупреждения нет. Перевешиваю на gcc15.
|

Description
Ivan Zakharyaschev 2019-02-21 14:15:27 MSKgcc8-8.2.1-alt5.x86_64 When compiling rpm-build (from Sisyphus), we see warnings like: interdep.c: In function 'makeReq1': interdep.c:116:8: warning: function called through a non-compatible type hge(pkg1->header, RPMTAG_REQUIRENAME, NULL, (void **) &reqNv, &c) && ^~~ interdep.c:117:8: warning: function called through a non-compatible type hge(pkg1->header, RPMTAG_REQUIREVERSION, NULL, (void **) &reqVv, NULL) && ^~~ interdep.c:118:8: warning: function called through a non-compatible type hge(pkg1->header, RPMTAG_REQUIREFLAGS, NULL, (void **) &reqFv, NULL); ^~~ where the source code is like this: const HGE_t hge = (HGE_t)headerGetEntryMinMemory; int ok = hge(pkg1->header, RPMTAG_REQUIRENAME, NULL, (void **) &reqNv, &c) && hge(pkg1->header, RPMTAG_REQUIREVERSION, NULL, (void **) &reqVv, NULL) && hge(pkg1->header, RPMTAG_REQUIREFLAGS, NULL, (void **) &reqFv, NULL); Removing the const qualifier makes the warning go away. Isn't it a strange reason to give a warning in this case? The const qualifier should affect just the variable where the pointer is stored and not the type of the function.