This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: farg


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]