Bug 986923 - gcc ignore warning implicit-function-declaration [NEEDINFO]
gcc ignore warning implicit-function-declaration
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
25
x86_64 Linux
unspecified Severity high
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-22 08:39 EDT by Lukas Slebodnik
Modified: 2017-11-21 01:45 EST (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-11-21 01:45:55 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
lslebodn: needinfo? (jakub)


Attachments (Terms of Use)
source code file. (1.50 KB, text/x-csrc)
2013-07-22 08:39 EDT, Lukas Slebodnik
no flags Details
Posprocesed source file (47.61 KB, text/x-csrc)
2013-07-22 08:42 EDT, Lukas Slebodnik
no flags Details
ccache log file (32.58 KB, text/plain)
2013-08-29 04:13 EDT, Lukas Slebodnik
no flags Details

  None (edit)
Description Lukas Slebodnik 2013-07-22 08:39:59 EDT
Created attachment 776890 [details]
source code file.

Description of problem:
I did a review of some patches in sssd and I found a warning
"warning: implicit declaration of function". It was strange, because author of the patch uses cflag "-Werror" and he could not see any warning.
We found out, that it is only reproducible with fedora 19 and newer version of gcc. I tried to reproduce this on virtual machine, but warnings were produced normally. It seems like it allways reproducible with fedora 19 and Lenovo T530

I did some investigation and this bug seems to be in gcc pre-processor.
I generated preprocessed file:
gcc -E -c -o ldap_id_postproc.c ldap_id.c
If I try to compile ldap_id_postproc.c, then warnings are also ignored on virtual machine.




Version-Release number of selected component (if applicable):
sh-4.2$ rpm -q gcc libtalloc-devel
gcc-4.8.1-1.fc19.x86_64
libtalloc-devel-2.0.8-2.fc19.x86_64

How reproducible:
Always

Steps to Reproduce:
1. yum install gcc libtalloc-devel -y
2. try to compile attached file:
   gcc -Wimplicit-function-declaration -Werror -c -o ldap_id.o ldap_id.c

Actual results:
sh-4.2$ gcc -Wimplicit-function-declaration -Werror -c -o ldap_id.o ldap_id.c
sh-4.2$ echo $?
0

Expected results:
sh-4.2$ gcc -Wimplicit-function-declaration -Werror -c -o ldap_id.o ldap_id.c
error: implicit declaration of function ‘sdap_get_user_and_group_recv’ [-Werror=implicit-function-declaration]
     sdap_get_user_and_group_recv(subreq, &state->dp_error, &state->sdap_ret);
     ^
cc1: all warnings being treated as errors
sh-4.2$ echo $?
1

Additional info:
Compilation fails with additional flag "-P". This could not be considered as a workaround, because debug symbols will not be generated with right way.

sh-4.2$ gcc -P -Wimplicit-function-declaration -Werror -c -o ldap_id.o ldap_id.c
/home/user/.ccache/tmp/ldap_id.tmp.unused-4-233.brq.redhat.com.21902.i: In function ‘sdap_handle_acct_req_done’:
/home/user/.ccache/tmp/ldap_id.tmp.unused-4-233.brq.redhat.com.21902.i:914:5: error: implicit declaration of function ‘sdap_get_user_and_group_recv’ [-Werror=implicit-function-declaration]
     sdap_get_user_and_group_recv(subreq, &state->dp_error, &state->sdap_ret);
     ^
cc1: all warnings being treated as errors
sh-4.2$ echo $?
1
Comment 1 Lukas Slebodnik 2013-07-22 08:42:44 EDT
Created attachment 776891 [details]
Posprocesed source file

This file was generated from the first attachment with command:
gcc -E -c -o ldap_id_postproc2.c ldap_id.c
Comment 2 Jakub Jelinek 2013-08-27 14:41:12 EDT
grep ldap_id.c ldap_id.i
# 1 "ldap_id.c"
# 1 "ldap_id.c"
# 3 "ldap_id.c" 2
 "ldap_id.c"
# 35 "ldap_id.c" 3 4
The 2 there means system header, supposedly you are using ccache and it messes up the notion of system header directories?
You get the error with -Wsystem-headers in addition to -Wimplicit-function-definition -Werror, but I'd strongly recommend uninstalling the mess called ccache, especially if the problem goes away without it.
Comment 3 Lukas Slebodnik 2013-08-28 09:40:19 EDT
Yes I have installed ccache, but I did not realized it. It could be installed as a dependency of another samba library. I am not sure.

Compilation fail with flag -Wsystem-headers.
Thank you very much for two possible solutions.
Comment 4 Lukas Slebodnik 2013-08-28 09:46:42 EDT
I am not sure where problem is, because file can be compiled without problems on fedora 18 (with default version of ccache and backported version of ccache from fedora 19)

#logout and login
[root@fedora18 ~]# rm -rf ~/.ccache/
[root@fedora18 ~]# rpm -q gcc glibc talloc ccache
gcc-4.7.2-8.fc18.x86_64
glibc-2.16-34.fc18.x86_64
libtalloc-2.0.8-1.fc18.x86_64
ccache-3.1.9-1.fc18.x86_64
[root@fedora18 ~]# gcc -Wall -Werror -c ldap_id.c
ldap_id.c: In function ‘sdap_handle_acct_req_done’:
ldap_id.c:47:5: error: implicit declaration of function ‘sdap_get_user_and_group_recv’ [-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors
[root@fedora18 ~]# echo $?
1

#logout and login
[root@fedora18 ~]# rm -rf ~/.ccache/
[root@fedora18 ~]# rpm -q gcc glibc talloc ccache
gcc-4.7.2-8.fc18.x86_64
glibc-2.16-34.fc18.x86_64
libtalloc-2.0.8-1.fc18.x86_64
ccache-3.1.9-3.fc18.x86_64
[root@fedora18 ~]# gcc -Wall -Werror -c ldap_id.c
ldap_id.c: In function ‘sdap_handle_acct_req_done’:
ldap_id.c:47:5: error: implicit declaration of function ‘sdap_get_user_and_group_recv’ [-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors
[root@fedora18 ~]# echo $?
1

Problem is only with fedora 19 and thus with rhel7.
I was not able to rebuild ccache from fedora 18 in mock for fedora 19.
I tried default version of ccache from fedora 19 and lates version from fedora rawhide.

#logout and login
[root@fedora19 ~]# rm -rf ~/.ccache/
[root@fedora19 ~]# rpm -q gcc glibc libtalloc ccache
gcc-4.8.1-1.fc19.x86_64
glibc-2.17-14.fc19.x86_64
libtalloc-2.0.8-2.fc19.x86_64
ccache-3.1.9-3.fc19.x86_64
[root@fedora19 ~]# gcc -Wall -Werror -c ldap_id.c
[root@fedora19 ~]# echo $?
0

#logout and login
[root@fedora19 ~]# rm -rf ~/.ccache/
[root@fedora19 ~]# rpm -q gcc glibc libtalloc ccache
gcc-4.8.1-1.fc19.x86_64
glibc-2.17-14.fc19.x86_64
libtalloc-2.0.8-2.fc19.x86_64
ccache-3.1.9-4.fc19.x86_64
[root@fedora19 ~]# gcc -Wall -Werror -c ldap_id.c
[root@fedora19 ~]# echo $?
0

Do you think, that problem is in gcc or ccache?
Comment 5 Jakub Jelinek 2013-08-28 09:52:09 EDT
If you can't reproduce it with ccache uninstalled, then it certainly is a bug in ccache.  Guess you can strace it to see with what command line options it invokes gcc to preprocess the source, I bet it has some wrong -isystem somewhere, otherwise it wouldn't end up with 2 in the line notes.
Comment 6 Lukas Slebodnik 2013-08-29 04:07:00 EDT
I found out another workaround for ccache. If I set environment variable CCACHE_CPP2 warnings will be shown.

bash# export CCACHE_LOGFILE=./ccache.log
bash# ccache -z -c -C
Statistics cleared
Cleaned cache
Cleared cache
bash# ccache /usr/bin/gcc -c -Wall ldap_id.c -o ldap_id.o
bash# echo $?
0
bash# ccache -z -c -C
Statistics cleared
Cleaned cache
Cleared cache
bash# CCACHE_CPP2=1 ccache /usr/bin/gcc -c -Wall ldap_id.c -o ldap_id.o
ldap_id.c: In function ‘sdap_handle_acct_req_done’:
ldap_id.c:47:5: warning: implicit declaration of function ‘sdap_get_user_and_group_recv’ [-Wimplicit-function-declaration]
     sdap_get_user_and_group_recv(subreq, &state->dp_error, &state->sdap_ret);
     ^
ldap_id.c: In function ‘sdap_handle_acct_req_send’:
ldap_id.c:39:28: warning: ‘subreq’ is used uninitialized in this function [-Wuninitialized]
     tevent_req_set_callback(subreq, sdap_handle_acct_req_done, req);
                            ^
ldap_id.c: In function ‘sdap_handle_acct_req_done’:
ldap_id.c:47:33: warning: ‘state’ is used uninitialized in this function [-Wuninitialized]
     sdap_get_user_and_group_recv(subreq, &state->dp_error, &state->sdap_ret);
                                 ^

bash# rpm -q ccache gcc
ccache-3.1.9-4.fc19.x86_64
gcc-4.8.1-1.fc19.x86_64
Comment 7 Lukas Slebodnik 2013-08-29 04:13:04 EDT
Created attachment 791641 [details]
ccache log file

I am attaching ccache log file, which was generated using commands from 986923#c6
Comment 8 Jakub Jelinek 2013-08-29 04:35:45 EDT
Actually, if you uninstall ccache, can you reproduce the warning/error with additional -save-temps option to gcc?
If yes, what is the difference between ldap_id.i and the ccache created preprocessed source?
Comment 9 Lukas Slebodnik 2013-08-29 06:59:33 EDT
I cannot compare ldap_id.i to ccache created preprocessed source.

You can see in ccache log https://bugzilla.redhat.com/attachment.cgi?id=791641
that file ldap_id.tmp.vm-085.idm.lab.eng.brq.redhat.com.32373.i was removed.

[2013-08-29T10:00:01.049917 32373] Executing /usr/bin/gcc -c -Wall -o /root/.ccache/c/1/5e835d87813fa5192ad24165006fea-48893.o.tmp.vm-085.idm.lab.eng.brq.redhat.com.32373 /root/.ccache/tmp/ldap_id.tmp.vm-085.idm.lab.eng.brq.redhat.com.32373.i
[2013-08-29T10:00:01.050069 32376] Unlink /root/.ccache/c/1/5e835d87813fa5192ad24165006fea-48893.o.tmp.stdout.vm-085.idm.lab.eng.brq.redhat.com.32373

I prepared minimal VM with fedora 19 and then I tried to use flag "-save-temps" with various compiler and compiler flags.
/usr/bin/gcc -Wall -Wsystem-headers -Werror -save-temps -c ../ldap_id.c
/usr/bin/gcc -Wall -Wsystem-headers -Werror -save-temps -c ../ldap_id.c
/usr/bin/clang -Wall -Werror -save-temps -c ../ldap_id.c

Output:
-------------------------------
[root@vm-181 gcc_dir]# /usr/bin/gcc -Wall -Werror -save-temps -c ../ldap_id.c
[root@vm-181 gcc_dir]# echo $?
0

[root@vm-181 gcc_dir]# /usr/bin/gcc -Wall -Wsystem-headers -Werror -save-temps -c ../ldap_id.c
../ldap_id.c: In function ‘sdap_handle_acct_req_done’:
../ldap_id.c:47:5: error: implicit declaration of function ‘sdap_get_user_and_group_recv’ [-Werror=implicit-function-declaration]
     sdap_get_user_and_group_recv(subreq, &state->dp_error, &state->sdap_ret);
     ^
cc1: all warnings being treated as errors
[root@vm-181 gcc_dir]# echo $?
1

[root@vm-181 gcc_dir]# cd ../clang_dir/
[root@vm-181 clang_dir]# /usr/bin/clang -Wall -Werror -save-temps -c ../ldap_id.c
../ldap_id.c:39:29: error: variable 'subreq' is uninitialized when used here [-Werror,-Wuninitialized]
    tevent_req_set_callback(subreq, sdap_handle_acct_req_done, req);
                            ^~~~~~
../ldap_id.c:33:30: note: initialize the variable 'subreq' to silence this warning
    struct tevent_req *subreq;
                             ^
                              = 0
../ldap_id.c:47:5: error: implicit declaration of function 'sdap_get_user_and_group_recv' is invalid in
      C99 [-Werror,-Wimplicit-function-declaration]
    sdap_get_user_and_group_recv(subreq, &state->dp_error, &state->sdap_ret);
    ^
../ldap_id.c:47:43: error: variable 'state' is uninitialized when used here [-Werror,-Wuninitialized]
    sdap_get_user_and_group_recv(subreq, &state->dp_error, &state->sdap_ret);
                                          ^~~~~
../ldap_id.c:46:45: note: initialize the variable 'state' to silence this warning
    struct sdap_handle_acct_req_state *state;
                                            ^
                                             = 0
3 errors generated.
[root@vm-181 clang_dir]# echo $?
1


Package versions:
-------------------------------
[root@vm-181 clang_dir]# rpm -q gcc glibc clang libtalloc-devel ccache
gcc-4.8.1-1.fc19.x86_64
glibc-2.17-14.fc19.x86_64
clang-3.3-0.6.rc3.fc19.x86_64
libtalloc-devel-2.0.8-2.fc19.x86_64
package ccache is not installed

I can provide access to this VM if you are unable to reproduce it.
Comment 10 Lukas Slebodnik 2013-10-16 13:13:22 EDT
According do previous comment 986923#c9, it doesn't seem to me that it is a problem in ccache.

Do you still think it is a problem in ccache?
Comment 11 Lukas Slebodnik 2013-10-16 13:15:44 EDT
According do previous comment 986923#c9, it doesn't seem to me that it is *NOT* a problem in ccache, because ccache was not installed on fresh virtual machine.

Do you still think it is a problem in ccache?
Comment 12 Lukas Slebodnik 2013-11-20 03:45:58 EST
Reassigning back to gcc
Comment 13 Lukas Slebodnik 2013-11-20 03:49:08 EST
Problem is in gcc >=4.8, because track-macro-expansion has by default value 2

sh-4.2# /usr/bin/gcc -Wall -Werror -save-temps -c ./ldap_id.c
sh-4.2# echo $?
0

sh-4.2# /usr/bin/gcc -ftrack-macro-expansion=0 -Wall -Werror -save-temps -c ./ldap_id.c
./ldap_id.c: In function ‘sdap_handle_acct_req_done’:
./ldap_id.c:47:5: error: implicit declaration of function ‘sdap_get_user_and_group_recv’ [-Werror=implicit-function-declaration]
     sdap_get_user_and_group_recv(subreq, &state->dp_error, &state->sdap_ret);
     ^
cc1: all warnings being treated as errors
sh-4.2# echo $?
1

sh-4.2# rpm -q gcc ccache libtalloc-devel
gcc-4.8.2-1.fc19.x86_64
package ccache is not installed
libtalloc-devel-2.0.8-2.fc19.x86_64
Comment 14 djcb 2014-01-18 13:22:42 EST
Related, I can reproduce a similar (same cause) problem on Fedora 20 with something minimal:

----
#include <glib.h>
int main (void)
{
         g_return_val_if_fail (0, "FOO");
}
----

$ gcc -c test.c -Wall -Werror -Wextra `pkg-config --cflags glib-2.0` && echo "ok"
ok

$ gcc -c test.c -Wall -Werror -Wextra -ftrack-macro-expansion=0  `pkg-config --cflags glib-2.0` && echo "ok"
test.c: In function 'main':
test.c:5:3: error: return makes integer from pointer without a cast [-Werror]
   g_return_val_if_fail (0, "FOO");
   ^
cc1: all warnings being treated as errors

So, ftrack-macro-expansion=2 seems to be a rather suboptimal default.
Comment 15 bugzilla.redhat.com 2014-04-30 12:04:52 EDT
I think this is upstream bug 60014:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60014
Comment 16 Fedora End Of Life 2015-01-09 14:02:39 EST
This message is a notice that Fedora 19 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 19. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained. Approximately 4 (four) weeks from now this bug will
be closed as EOL if it remains open with a Fedora 'version' of '19'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 19 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 17 Lukas Slebodnik 2015-01-09 15:17:44 EST
I'm able to reproduce bug even with gcc in fedora 21.
gcc-4.9.2-1.fc21.x86_64
Comment 18 Fedora End Of Life 2015-11-04 09:17:22 EST
This message is a reminder that Fedora 21 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 21. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '21'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 21 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 19 Lukas Slebodnik 2015-11-04 09:46:12 EST
I can reproduce (comment 13) eve on Fedora 23 with gcc-5.1.1-4.fc23.x86_64
Comment 20 Fedora End Of Life 2016-11-24 06:00:12 EST
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 21 Lukas Slebodnik 2016-11-24 06:08:47 EST
Reproducible with gcc-6.2.1-2.fc25.x86_64 as well (comment 13)
Comment 22 Fedora End Of Life 2017-11-16 13:43:08 EST
This message is a reminder that Fedora 25 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 25. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '25'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 25 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.
Comment 23 Lukas Slebodnik 2017-11-21 01:45:55 EST
(In reply to Lukas Slebodnik from comment #21)
> Reproducible with gcc-6.2.1-2.fc25.x86_64 as well (comment 13)

Seems to be fixed in gcc-6.4.1-1.fc25.x86_64. At least in my reproducer.
(and also in gcc-6.3.1-1.fc24.x86_64)

Note You need to log in before you can comment on or make changes to this bug.