Bug 59922 - -finstrument-functions emit false warning "control reaches end of non-void function"
Summary: -finstrument-functions emit false warning "control reaches end of non-void fu...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2014-01-23 16:14 UTC by Alexander
Modified: 2022-11-17 02:50 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-08-23 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander 2014-01-23 16:14:21 UTC
Example input:

---------- t.c ---------
int something();                                                                 
                                                                                 
int f(int arg) {                                                                 
 return 0;                                                                       
 (void)(false ? 1 : something());                                                
}   
-----------------------

$ c++ -c t.cc -finstrument-functions -Wall -Werror
t.cc: In function ‘int f(int)’:
t.cc:6:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
$ echo $?
1
$

But:

$ c++ -c t.cc -Wall -Werror
$ echo $?
0
$
Comment 1 Andrew Pinski 2014-01-23 18:37:51 UTC
There is another bug about a similar thing but with constructors/deconstructors.
-finstrument-functions inserts try/finally blocks in the code and the dead code is not removed before hand so the warning mechanism gets confused.
Comment 2 Andrew Pinski 2014-01-24 04:29:55 UTC
Related to bug 20681.
Comment 3 Eric Gallager 2017-08-23 16:02:02 UTC
Confirmed. Happens with optimization levels -O0 and -Os, but not -O1, -O2, -O3, -Og, or -Ofast.
Comment 4 Eric Gallager 2018-05-23 11:16:05 UTC
Kinda more important now that -Wreturn-type is on by default
Comment 5 Eric Gallager 2018-11-23 03:33:17 UTC
(In reply to Eric Gallager from comment #4)
> Kinda more important now that -Wreturn-type is on by default

...thus, cc-ing Martin Liska