Pelles C > Announcements

Release Candidate for version 11.00 is now available

<< < (2/12) > >>

Pelle:

--- Quote from: Marco on July 23, 2021, 04:39:57 PM ---Regarding to the warnings, when I free an allocated buffer, and the same buffer is also freed elsewhere, the compiler shows the following:
<snip>

--- End quote ---
Yes, I'm aware of this - that's why I called it "aggressive".
I have seen this for a few cases in my own code, and my solution was similar to yours.

It's somewhat tricky to separate the good warnings from the silly ones - maybe this can be improved over time... (I really like the good warnings, even if there is a little noise...)

John Z:
It ay be 'old style' but a simple change 'fixes' it.

--- Code: ---void foo(void)
{char *buffer = NULL;

  buffer = malloc(32);
  if (buffer == NULL) return;
  buffer[0] = '\0';

  DWORD dwRet = GetLastError();
  if (dwRet)
  {
        free(buffer);                     //<-- no 'fix' needed
        return;
  }

  free(buffer);                           //<-- no more warning
}
--- End code ---

John Z

Marco:

--- Quote from: Pelle on July 23, 2021, 05:09:21 PM ---Yes, I'm aware of this - that's why I called it "aggressive".
I have seen this for a few cases in my own code, and my solution was similar to yours.

It's somewhat tricky to separate the good warnings from the silly ones - maybe this can be improved over time... (I really like the good warnings, even if there is a little noise...)

--- End quote ---

I agree with you. As I said, thanks to the 'noise' of this version, I found out a couple of tricky bugs in my projects.


--- Quote from: John Z on July 23, 2021, 06:07:06 PM ---It ay be 'old style' but a simple change 'fixes' it.
<snip>

--- End quote ---

Hi John. I tried your same solution prior to posting the 'fix', but that not 'solve' it. The warning is still there.

John Z:

--- Quote from: Marco on July 23, 2021, 09:34:30 PM ---Hi John. I tried your same solution prior to posting the 'fix', but that not 'solve' it. The warning is still there.

--- End quote ---

Really - that makes it a bit more interesting.  I did not post it without testing and seeing a good result.
I just now went back and tested again in two different programs and get no errors with Level 2 warnings enabled.
lt also compiled w/o error under C99, C11, and C17.

I always want to use the most robust checking, am I missing some higher level checking setting?

Thanks Marco,

John Z

TimoVJL:
Thanks Pelle for a new version to test.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version