Sample Program
On-Line Demonstrations of FlexeLint and PC-lint (aka FlexeLint for Windows)
Bug of the Month for December 2004
Bug of the Month Samples
Our attempt to wish everyone a Merry Christmas, though syntactically correct, has a serious flaw. Can you find it?
Modify this example, if desired, and then hit the Analyse Code button
#include
typedef const char *PtrChar; typedef PtrChar *PtrPtrChar; PtrPtrChar message( PtrChar a, PtrChar b ) { PtrPtrChar p = (PtrPtrChar) new (char *)[10]; p[0] = a; p[1] = b; return p; } int main() { PtrPtrChar mc = message( "Merry", "Christmas" ); PtrPtrChar hny = message( "Happy", "New Year" ); printf( "%s %s\n", mc[0], mc[1] ); printf( "%s %s\n", hny[0], hny[1] ); return 0; }
Run FlexeLint on Bug of the Month Samples
Home
|
Examples
|
Contact
|
Order
PC-lint and FlexeLint are trademarks of Gimpel Software
Copyright © 2009, Gimpel Software