Orchid XP v8 a écrit :
> Mueen Nawaz wrote:
>> Orchid XP v8 wrote:
>>> Spot the mistake:
>>
>> Function lacks a return statement.
>
> Yup. A simple and obvious mistake. But unfortunately, not one the
> compiler warned me about. (I'm also curios to know exactly what the hell
> the function is returning... No doubt the reason there's no compiler
> warning is that this is actually a valid thing to do due to some bizare
> C language rule kept for compatibility or something random like that.)
>
If you are using g++, you can add the option -Wall to your command line.
The compiler should give a warning in this case... Well two actually,
one because the variable x is not used for anything and one because the
function does not return.
I'm leaving the explanation of why this is still legal to someone more
competent :-)
--
Vincent
Post a reply to this message
|