Skip to content

warning dangling pointer from gcc 13 #70

@freakout42

Description

@freakout42

severe warning from gcc 13 - this code exports a local variable res into upper js struct.

cc -O3 -DNDEBUG -fstack-protector -Wall -Werror -std=c99 -c -o elk.o elk.c
elk.c: In function ‘js_eval’:
elk.c:1396:12: error: storing the address of local variable ‘res’ in ‘*js.cstk’ [-Werror=dangling-pointer=]
 1396 |   js->cstk = &res;
      |   ~~~~~~~~~^~~~~~
elk.c:1389:11: note: ‘res’ declared here
 1389 |   jsval_t res = js_mkundef();
      |           ^~~
elk.c:1387:28: note: ‘js’ declared here
 1387 | jsval_t js_eval(struct js *js, const char *buf, size_t len) {
      |                 ~~~~~~~~~~~^~
cc1: all warnings being treated as errors
make[2]: *** [: elk.o] Error 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions