Hi John,
On 2021-09-03 6:53 p.m., John Reiser wrote:
On 9/3/21 12:31 PM, Eric Chamberland wrote:
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;
}
This report is interesting only because it is a bad example:
it does not specify what is the supposed error.
If you don't say what you believe it is, then how are valgrind
developers to know?
Yes, indeed, sorry for not giving a good example!
Besides, the "memcheck error" is covered in the valgrind FAQ.
Look it up in paragraph "4.6. Why doesn't Memcheck find ..."
Ok, thanks, the answer was there :
https://valgrind.org/docs/manual/faq.html#faq.overruns
The second and third errors are the logic errors of not checking
the return value of fopen and fread.
The fourth error is not documenting the expected invocation command line.
The fifth error is not checking argc.
The sixth error is not documenting the expected format of the input file.
Are you sure that you really are a programmer?
I am happy with your answer, no need to dive into this: you helped
someone! :)
Thanks again John!
Eric
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users
--
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