Bug 36147 - const function pointer leads to: warning: function called through a non-compatible type
Summary: const function pointer leads to: warning: function called through a non-compa...
Status: NEW
Alias: None
Product: Sisyphus
Classification: Development
Component: gcc8 (show other bugs)
Version: unstable
Hardware: all Linux
: P3 minor
Assignee: Gleb F-Malinovskiy
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-02-21 14:15 MSK by Ivan Zakharyaschev
Modified: 2019-02-22 07:50 MSK (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Zakharyaschev 2019-02-21 14:15:27 MSK
gcc8-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.