Thread View: comp.lang.c.moderated
2 messages
2 total messages
Started by Art Shelest
Fri, 19 Apr 1996 14:30
Ultimate bug
Author: Art Shelest
Date: Fri, 19 Apr 1996 14:30
Date: Fri, 19 Apr 1996 14:30
18 lines
882 bytes
882 bytes
Below is the bug I got to fix last night (in someone else's code).
It's not the actual code, but you'll get the idea:
void* AllocMem( size_t cbMem )
{
void* pMem = malloc( cbMem );
if( pMem )
memset( &pMem, 0, cbMem ); /* note & */
return pMem;
}
I wonder if Lint would ever catch this one.
The net effect that this function would never return (to where it should
return, anyway), ant took good 2 hours to find it in 200K+ lines of code.
_Art.
Re: Ultimate bug
Author: Dan Pop
Date: Sat, 20 Apr 1996 18:21
Date: Sat, 20 Apr 1996 18:21
29 lines
1305 bytes
1305 bytes
In <4l881k$76k@solutions.solon.com> Artyom@kansmen.com (Art Shelest) writes:
>Below is the bug I got to fix last night (in someone else's code).
>It's not the actual code, but you'll get the idea:
>
>void* AllocMem( size_t cbMem )
>{
> void* pMem = malloc( cbMem );
>
> if( pMem )
> memset( &pMem, 0, cbMem ); /* note & */
>
> return pMem;
>}
>
>I wonder if Lint would ever catch this one.
Never. Any kind of pointer (except function pointers and pointers to const
objects) is OK as the first argument of memset, which expects a void pointer.
Reading the programmer's mind and comparing it with programmer's code is
beyond the current state of the art in lint technology.
Dan
--
Dan Pop
CERN, CN Division
Email: danpop@mail.cern.ch
Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads