|
From: Karai C. <cs...@fr...> - 2006-08-16 15:20:51
|
Hi!
If you, developers are interested, I would write a new component for
valgrind, a precompiler.
The precompiler would modify the C/C++ code to detect more memory
errors in the program.
How it would work?
- one should compile with valgrind-cc instead of gcc
- valgrind-cc calls the gcc -E for getting a clean code
without macros and includes
- after that it modifies the code for further checks
- compiles the modified code
My precompiler could detect array bound errors, such as:
static int array [ 5 ];
void error()
{
array[ 10 ] = 10;
}
After the modifications:
static int array [ 5 ];
void error()
{
indexcheck(10,5);array[ 10 ] = 10;
}
void indexcheck( int i1, int i2 )
{
if( i1 < 0 || i1 >= i2 )
...
}
This could work for primitive types, where no operator[] is defined.
Do you think it worths to write such a component?
Thanks,
Csaba
|