Skip to content

Instantly share code, notes, and snippets.

@kaityo256
Created November 26, 2018 06:00
Show Gist options
  • Save kaityo256/9fed5399bb39bbaed26ca693989adfd1 to your computer and use it in GitHub Desktop.
Save kaityo256/9fed5399bb39bbaed26ca693989adfd1 to your computer and use it in GitHub Desktop.
SIGILL on MAC and g++
int func(int a){
}
int func2(int a){
return func(a);
}
int main(){
func2(1);
}
@kaityo256
Copy link
Author

$ gcc --version
gcc (Homebrew GCC 8.2.0) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ g++ --version
g++ (Homebrew GCC 8.2.0) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc -O1 ub3.c; ./a.out; echo $?
0

$ g++ -O1 ub3.c; ./a.out; echo $?
ub3.c: In function 'int func(int)':
ub3.c:2:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
zsh: illegal hardware instruction  ./a.out
132

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment