Fprintf bug in the interpreter

VIVE L’AMOUR!
I’ve found a serious bug in “fprintf”, when called in the interpreter - the following code misbehaves (‘NUL’ characters are “discarded”): [-X #-o

FILE *f = fopen(“test.out”, “w”);
fprintf(f, “%c%c%c%c”, 44, 0, 44, 0);
fclose(f);

No problem in the compiled code (e.g. when using ACLiC, ‘NUL’ characters are present in the output file). =D>

I am stupid. No?
Pepe Le Pew.

VIVE L’AMOUR!
I’ve found another strictly related bug … [-X #-o

The following piece of code will “hang” ROOT (current v5-28-00-patches) …

FILE *f = fopen(“test.out”, “w”);
fprintf(f, “%lc”, 0xff);
// fclose(f); // no need to close the file, you have to “Ctrl-Z” ROOT and do “kill %1” anyhow :unamused:

BTW. I also get “Error: Invalid type ‘wint_t’ in declaration …” (a ‘wint_t’ is actually what “%lc” expects). 8-[

Everyone should 'ave a 'obby, don’t you think? Mine is making love.
Pepe Le Pew.

P.S. “making love” = “discovering bugs in software” :-&

Hi,

Indeed, CINT does not handle properly this case (internally it is a bit confused where the null character is intentional or the end of the string processed so far). Solving this issue would require significant work and thus we are not currently in a position to solve it (we are looking at possible alternative to CINT).

Cheers,
Philippe.

VIVE L’AMOUR!
wouldn’t it be a good idea to create a page with “Known Problems”? :-k
I am stupid. No?
Pepe Le Pew.

Hi,

You can see a long list at root.cern.ch/viewvc/trunk/cint/doc/limitati.txt (which will be updated to contain the printf limitation you discovered).

Philippe.