serious: GCC 2.95.3 accepts illegal function call
Michael Noisternig
michael.noisternig@sbg.ac.at
Sat Sep 8 00:49:00 GMT 2001
Thanks for your "introduction" to C. I know C/C++ very well - at least I
thought so ;-)
NO, I didn't know that () wouldn't mean (void) in C. I do programming in
C++ normally where this is NOT accepted - and I always thought C++ was
downwards compatible to C, some sort of a layer !?
YES, uint64 is unsigned, i just manually inserted the typedef in this
e-mail and forget the 'unsigned'.
YES, the parameter I hand over is GARUANTEED to be smaller than 2^31! I
know what I do!
Anyway, thanks after all again,
Michael Noisternig.
Daniel Berlin schrieb:
>
> Michael Noisternig <michael.noisternig@sbg.ac.at> writes:
>
> > Check this:
> >
> > --- begin code ---
> >
> > typedef long long uint64;
> >
> > uint64 calculate_cpu_timing_factors (unsigned int instr)
> > {
> > // ...
> > }
> >
> > uint64 calculate_cpu_timing()
> > {
> > return calculate_cpu_timing(calculate_cpu_timing(10000)/1024);
> > }
> >
> > --- end code ---
> >
> > This piece of code is happily accepted by the compiler! Check it 'til
> > you find the error, it took me the whole day :-(((
> For starters, you have long long, rather than unsigned long long,
> typedef'd to uint64.
>
> Second, if you say "uint64 calculate_cpu_timing(void)" instead of
> "uint64 calculate_cpu_timing", you'd get:
>
> testul.c: In function `calculate_cpu_timing':
> testul.c:8: too many arguments to function `calculate_cpu_timing'
> testul.c:8: too many arguments to function `calculate_cpu_timing'
>
> Third, if you really intend to call calculate_cpu_timing_factors with
> those arguments, then you should probably make the argument to it a
> uint64.
> Unless you have a guarantee that the uint64 it returns, divided by
> 1024, will now be in the range of unsigned int.
>
> >
> > Michael Noisternig.
>
> --
> "I just got out of the hospital. I was in a speed reading
> accident. I hit a book mark and flew across the room.
> "-Steven Wright
More information about the Gcc-bugs
mailing list