Ryan Mansfield(deleted)
|
Re: return of incompatible reference does not trough an error on
qcc
|
Ryan Mansfield(deleted)
08/15/2008 12:34 PM
post11875
|
Re: return of incompatible reference does not trough an error on
qcc
Annam Krupakar wrote:
> Hi ,
>
> The following sample program does not trough either compiler or linker error when compiled using qcc.
>
> $ qcc test.cc
>
> But, when I try to compile it with gcc it troughs the following error
>
> test.cc: In function `int main()':
> test.cc:11: error: invalid initialization of non-const reference of type 'unsign
> ed int&' from a temporary of type 'unsigned int'
> test.cc:3: error: in passing argument 1 of `void testa(unsigned int&)'
>
> Somebody please tell me why the qcc is not detecting the incompatible reference type, ofcourse the output file fails
to return the expected value at runtime..
qcc is just a compiler driver. By default, when you invoke qcc t.cc it
uses gcc 2.95, and you are comparing it to a newer version of gcc.
Earlier versions of gcc (pre-gcc 3.4) were very permissive with respect
to C++ and did not catch this error.
You can download gcc 4.2 from the core developments project on the
foundry and then change the default compiler qcc uses.
Regards,
Ryan Mansfield
|
|
|