Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storing address of local variable #1

Open
ghost opened this issue Dec 6, 2022 · 0 comments
Open

Storing address of local variable #1

ghost opened this issue Dec 6, 2022 · 0 comments

Comments

@ghost
Copy link

ghost commented Dec 6, 2022

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants