[Bug c++/91585] New: segfault when calling a non void function without a return statement

2019-08-28 Thread lucien.gentis at waika9 dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91585

Bug ID: 91585
   Summary: segfault when calling a non void function without a
return statement
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: lucien.gentis at waika9 dot com
  Target Milestone: ---

Created attachment 46773
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46773&action=edit
file generated when -save-temps option is specified

GCC : 8.3.0
Linux Debian 10 - kernel 4.19.0-5-amd64
Attachment : test1.ii

Hello,

Building following code (see attachement) via command 'gcc -g -Wall -O2
-save-temps test1.cc -o test1'

/
#include 
int f(int a) {
printf("function f called - a = %d\n",a);
}
int main(void) {
f(1);
}
/

compiler output :
test1.cc: In function 'int f(int)':
test1.cc:4:1: warning: no return statement in function returning non-void
[-Wreturn-type]

but if I execute test1, I get :
function f called - a = 1
Erreur de segmentation

Maybe it's not a bug, but since program crashes with a segfault, shouldn't the
compiler send an error instead of a warning ?

PS : same program does not crash if compiled via GCC 7.4.0

[Bug c++/91585] segfault when calling a non void function without a return statement

2019-08-29 Thread lucien.gentis at waika9 dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91585

--- Comment #2 from lucien.gentis at waika9 dot com ---
(In reply to Marek Polacek from comment #1)
> You can use -Werror if you want errors.  Not a bug.

Effectively, if it is the expected behaviour, it's not a bug.

About -Werror, I think it turns all warnings into errors.
With this option, Compiler says : "test1.cc:4:1: error: no return statement in
function returning non-void [-Werror=return-type]
So, I use -Wall -Werror=return-type, in order only warnings about non void
function without return statement get turned into errors.

Thanks for your help.