Skip to content

Storing address of local variable #1

Description

cc -Wall -Werror -std=c99 -pedantic -ggdb -I./th/readargs/src  -c -o src/th_test.o src/th_test.c
src/th_test.c: In function ‘stack_report_final’:
src/th_test.c:150:19: error: storing the address of local variable ‘last_stack’ in ‘*stack_pointer’ [-Werror=dangling-pointer=]
  150 |    *stack_pointer = (const char*)&last_stack;
      |    ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
src/th_test.c:149:8: note: ‘last_stack’ declared here
  149 |    int last_stack;
      |        ^~~~~~~~~~
src/th_test.c:149:8: note: ‘closure’ declared here
cc1: all warnings being treated as errors
make: *** [Makefile:40: src/th_test.o] Error 1

System

$ gcc --version
gcc (GCC) 12.2.0
Copyright (C) 2022 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.

$ make --version
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions