This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: farg
- To: Maciej Hrebien <m_hrebien at poczta dot onet dot pl>
- Subject: Re: farg
- From: Martin Sebor <sebor at roguewave dot com>
- Date: Sat, 24 Mar 2001 18:09:23 -0700
- CC: gcc-bugs at gcc dot gnu dot org
- Organization: Rogue Wave Software, Inc.
- References: <001501c0b45f$c1ecfa80$51054dd5@igra.pl>
Maciej Hrebien wrote:
>
> Hello!!
>
> Please look at this:
>
> #include <iostream.h>
>
> struct S
> { int a;
> S(int x):a(x){}
> };
>
> void fun(S* s, S& z)
> {
> cout<<(*s).a<<" "<<z.a<<endl;
> }
>
> main()
^^^^
Return type missing.
> {
> S o(11);
> fun(&S(10),o);
^^^^^^
You can't take the address of a temporary (5.3.1, p2).
> fun(&o,S(10)); // !!!
^^^^^
You can't initialize a non-const reference with a temporary (8.5.3, p5).
> return 0;
> }
>
> g++-2.95.2 gives me some errors in line marked with "!!!".
> Why?? It shoudn't be problems with this.
Because the code is ill-formed.
Regards
Martin