Windows Dumping Stack Trace

May 1, 2020 at 9:59am
I dont know how, but this simple code produce a stack trace error.. exactly when i add the arrowed line..
Do you guys know why?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <errno.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <cstring>
#include <stdio.h>
#include <unistd.h>

#define MAX_LINE  200

 int main(){
    //
    int ch = 0;
	
    //
    char* line = (char*)malloc(MAX_LINE * sizeof(char));
    char* infpath = (char*)malloc(sizeof(char) * MAX_LINE);
    char* fpath = (char*)malloc(sizeof(char)* MAX_LINE);
    char* initch = NULL;
    initch = line; // <-- WHEN I ADD THIS LINE

    free(line);
    free(infpath);
    free(fpath);
    return 0;
}
Last edited on May 1, 2020 at 10:01am
May 1, 2020 at 10:56am
Doesn't present any problems on my PC.
May 1, 2020 at 11:08am
Cygwin is the isssue i guess..

0 [main] a 1536 cygwin_exception::open_stackdumpfile: Dumping stack trace to a.exe.stackdump
Last edited on May 1, 2020 at 11:08am
May 1, 2020 at 12:48pm
it works fine on my cygwin with
-Wall -Wextra -std=c++17 -pedantic-errors -O3 -s
i have not updated too recently... g++ is 7.4
Topic archived. No new replies allowed.