help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: casting from unsigned short int to unsigned int (on gcc 3.4.4, compi


From: whizz_kid
Subject: Re: casting from unsigned short int to unsigned int (on gcc 3.4.4, compiles fine with 2.95.1)
Date: 8 Mar 2006 00:26:36 -0800
User-agent: G2/0.2

Thanks Paul for your prompt reply and the explaination of the problem.
Yes, actually the problem got solved by changing the const'ness of the
last param. Still thinking why didn't gcc 2.95 complained for the
same!!

With Regards,
Raj

Paul Pluzhnikov wrote:
> "whizz_kid" <techybrainz@gmail.com> writes:
>
> > Can anyone please tell me whats happenning here....??
>
> The result of a cast is not an l-value, and can't be bound to
> non-const reference.
>
> Consider:
>
>   short s;
>   int &r = (int)s;
>   r = 0xFFFFFFFF;
>
> If the compiler allowed binding 'r' to 's' (i.e. if &r == &s),
> then the assignment to 'r' would have resulted in stack corruption
> (assuming sizeof(short) < sizeof(int)).
>
> If Class1::function1() doesn't modify 'ret' parameter, make it
> 'const TDF_U32 &'.
>
> If it does, you *must* supply a modifiable value of type TDF_U32;
> you can't use '(TDF_U32)obj.retsend' any more then you can use
> '(TDF_U32)42' ...
>
> Cheers,
> --
> In order to understand recursion you must first understand recursion.
> Remove /-nsp/ for email.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]