As part of an experiment using custom stacks, I wanted a function to return the address of a stack allocated char buffer.
// return pointer to stack variabl
GCC deliberately returns NULL
in this case as can be seen from the code:
tree zero = build_zero_cst (TREE_TYPE (val));
gimple_return_set_retval (return_stmt, zero);
update_stmt (stmt);
Newer versions of GCC and Clang exploit undefined behavior more aggressively so this check is not suprising. It also makes code fail fast which is a good thing in most cases (not yours, apparently).