1

In this example will be called deconstructor of nonexisting object. G++ version 5.3, compiling with -Werror .

vector<vector<float>> segfault()
{

}

int main()
{
    segfault();
    return 0;
}
biv
  • 1,613
  • 3
  • 13
  • 21
  • This doesn't compile with the `-Werror` flag. It does without that flag because a non-returning function that is non-void is just a warning not an error. – Eli Sadoff Oct 19 '16 at 20:36
  • 2
    `-Wall` adds a warning about missing a return statement; in conjunction with `-Werror`, that will be treated as an error, so the code won't compile. – Jerry Coffin Oct 19 '16 at 20:39
  • **-Werror=return-type** working, thank. – biv Oct 19 '16 at 20:39

1 Answers1

2

Both gcc and clang have the option -Wreturn-type.
It is turned on implicitly when using -Wall.
To make it is a compiler error, use -Werror=return-type.

Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271