Hi,
I have a simple test and valgrind seems to not see the error:
cat fread.cc && clang++ -o fread fread.cc && valgrind ./fread
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char ** argv){
int lA {1};
FILE * f = fopen ( argv[0] , "rb" );
fread(&lA,2*sizeof(int),1,f);
std::cout << "Hello: "<< lA << std::endl;
return 0;
}
==16241== Memcheck, a memory error detector
==16241== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==16241== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==16241== Command: ./fread
==16241==
Hello: 1179403647
==16241==
==16241== HEAP SUMMARY:
==16241== in use at exit: 472 bytes in 1 blocks
==16241== total heap usage: 4 allocs, 3 frees, 78,296 bytes allocated
==16241==
==16241== LEAK SUMMARY:
==16241== definitely lost: 0 bytes in 0 blocks
==16241== indirectly lost: 0 bytes in 0 blocks
==16241== possibly lost: 0 bytes in 0 blocks
==16241== still reachable: 472 bytes in 1 blocks
==16241== suppressed: 0 bytes in 0 blocks
==16241== Rerun with --leak-check=full to see details of leaked memory
==16241==
==16241== For lists of detected and suppressed errors, rerun with: -s
==16241== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
We just discovered this error that we got into our code since many
years... and even if we use valgrind it didn't detected it...
Is there any command line options I can add to valgrind to make it
detect the error?
Thanks,
Eric
--
Eric Chamberland, ing., M. Ing
Professionnel de recherche
GIREF/Université Laval
(418) 656-2131 poste 41 22 42
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users