Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Ubuntu 20.04.1 LTS (Focal Fossa)
- gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0
- gcc -std=c99 -Wall -Wextra -Wpedantic -Wshadow -O0 -DDEBUG -g main.c
- Program received signal SIGSEGV, Segmentation fault.
- 0x0000555555555180 in main () at main.c:31
- 31 {
- gcc -std=c99 -Wall -Wextra -Wpedantic -Wshadow -O1 -DNDEBUG -g main.c OK
- gcc -std=c99 -Wall -Wextra -Wpedantic -Wshadow -O2 -DNDEBUG -g main.c OK
- gcc -std=c99 -Wall -Wextra -Wpedantic -Wshadow -O3 -DNDEBUG -g main.c OK
- edit:
- possible stack overflow
- solution:
- use malloc
- https://pastebin.com/fYRAbMtb
- or https://pastebin.com/EuPakt7a
- Tnx to ##C on Freenode !
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdint.h>
- #include <stdbool.h>
- #define TEST_A_MAX_SIZE 1000000
- struct thread_test_a
- {
- uint32_t variables[TEST_A_MAX_SIZE];
- uint32_t test_count;
- };
- int main()
- { // line 31
- struct thread_test_a thread_test_1;
- struct thread_test_a thread_test_2;
- struct thread_test_a thread_test_3;
- thread_test_1.test_count = TEST_A_MAX_SIZE;
- thread_test_2.test_count = 10;
- thread_test_3.test_count = 50;
- thread_test_1.variables[TEST_A_MAX_SIZE-1] = 1;
- thread_test_2.variables[10] = 2;
- thread_test_3.variables[50] = 3;
- printf( "%d\n", thread_test_1.variables[TEST_A_MAX_SIZE-1] );
- printf( "%d\n", thread_test_2.variables[10] );
- printf( "%d\n", thread_test_3.variables[50] );
- return 0;
- }
Add Comment
Please, Sign In to add comment