File tree Expand file tree Collapse file tree 3 files changed +37
-1
lines changed
regression/cbmc/human-readable-error-on-wrong-main-signature Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 1+ #include <assert.h>
2+ #include <stddef.h>
3+
4+ struct foo
5+ {
6+ int x ;
7+ int y ;
8+ };
9+
10+ int main (struct foo * p )
11+ {
12+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ main.c
3+
4+ 'main' with signature .* found
5+ ^EXIT=6$
6+ ^SIGNAL=0$
7+ --
8+ Invariant check failed
9+ --
10+ This is just to check that CBMC doesn’t crash when we see a ‘main’ function
11+ with an unexpected signature, see https://github.com/diffblue/cbmc/issues/5415
Original file line number Diff line number Diff line change 1818#include < linking/static_lifetime_init.h>
1919
2020#include " c_nondet_symbol_factory.h"
21+ #include " expr2c.h"
2122
2223exprt::operandst build_function_environment (
2324 const code_typet::parameterst ¶meters,
@@ -473,7 +474,19 @@ bool generate_ansi_c_start_function(
473474 }
474475 }
475476 else
476- UNREACHABLE;
477+ {
478+ const namespacet ns{symbol_table};
479+ const std::string main_signature = type2c (symbol.type , ns);
480+ throw invalid_source_file_exceptiont{
481+ " 'main' with signature '" + main_signature +
482+ " ' found,"
483+ " but expecting one of:\n "
484+ " int main(void)\n "
485+ " int main(int argc, char *argv[])\n "
486+ " int main(int argc, char *argv[], char *envp[])\n "
487+ " If this is a non-standard main entry point please provide a custom\n "
488+ " entry function and point to it via cbmc --function instead" };
489+ }
477490 }
478491 else
479492 {
You can’t perform that action at this time.
0 commit comments