1

Basic hello world program using MinGW and gcc with no additional flags. I'm confused why I'm getting the errors 'unaddressable access', 'possible leak', and '4134 byte(s) of still-reachable allocation'.

Target: x86_64-w64-mingw32 using gcc version 8.2.0

#include <stdio.h>

int main() {
    printf("Hello World");
    return 0;
}

Error message from Dr. Memory: Error message from Dr. Memory

Shouldn't there be no errors at all from a simple program like this? Maybe if I could get some insight into what is going on.

the busybee
  • 10,755
  • 3
  • 13
  • 30
26F
  • 13
  • 7
  • 1
    Please don't post text as screenshot, you can copy it into your question. -- What does running it with `-show_reachable` give you? -- `printf()` might allocate memory. – the busybee Feb 03 '21 at 06:50

1 Answers1

0

I think that when you want to print something on the screen you need to use, in general, int argc and argv[], specifically char *argv[] inside "()" after main since, of course you a string is an argument, and naturally. The program will be like:

#include <stdio.h>

int main(int argc, char *argv[]) {
    printf("Hello World");
    return 0;
}

Observe that now the program receives an argument of type char *argv[] and the number of them is being stored in argc. The unadressible was due, possibly, to the fact that it wasn't possible to know the size of the allocated array to be printed.

  • hmm. It's still displaying the same error message. I might be wrong but I would have thought the compiler was smart enough to find the length of the "Hello World." I'm not an expert which is why I asked. – 26F Feb 03 '21 at 07:29
  • Then you should try to use the show_reachable for details. – João Víctor Melo Feb 03 '21 at 09:51
  • Indeed it's even possible that you have a problem with the segmentation table, this is, you are trying to access more memory than this table permits. – João Víctor Melo Feb 03 '21 at 20:54
  • I'm getting these errors: http://codepad.org/59nIA2VG – 26F Feb 03 '21 at 21:39