Skip to content
Snippets Groups Projects
Commit 0e14c5f0 authored by Dominik Zobel's avatar Dominik Zobel
Browse files

Add compiler flag example

parent d4c8bfb5
No related branches found
No related tags found
1 merge request!56Debugging Strategies lecture notes
Pipeline #66926 passed
...@@ -462,9 +462,49 @@ $\Rightarrow$ HPC systems usally provide native compiler plus gcc/gfortan. Try b ...@@ -462,9 +462,49 @@ $\Rightarrow$ HPC systems usally provide native compiler plus gcc/gfortan. Try b
## Compiler flags example ## Compiler flags example
_Example program with issue illustrating the compiler flags_ ::::::::{.columns}
:::{.column width=45%}
```c
#include <stdlib.h>
int main() {
int number = 1;
int* ptr;
ptr = &number;
free(ptr);
// ERROR: Trying to free
// memory from stack
return 0;
}
```
Compiling with
`gcc inv_ptr.c -o inv_ptr`
:::
:::{.column width=55% .smaller}
```
inv_ptr.c: In function ‘main’:
inv_ptr.c:8:4: warning: ‘free’ called on unallocated object ‘number’ [-Wfree-nonheap-object]
8 | free(ptr);
| ^~~~~~~~~
inv_ptr.c:4:8: note: declared here
4 | int number = 1;
| ^~~~~~
```
:::
::::::::
TODO
## Fixing run-time errors ## Fixing run-time errors
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment