This is the mail archive of the gcc@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: C++ bug (references)


On Fri, Feb 26, 1999 at 10:08:11AM -0800, Joe Buck wrote:
> Because you are passing a non-lvalue to a non-const reference.  Some
> compilers will just give you a hard error.  HP's aCC calls it a
> "future error" and says
> 
> Error (future) 438: "ref.cxx", line 12 # The initializer for a non-constant reference must be an lvalue. Try changing 'int &' to 'const int &' at ["ref.cxx", line 3].
>         func((int)val);
>         ^^^^^^^^^^^^^^ 
> 
> It, like egcs, then implements the ARM behavior of making a temporary.
SCO UnixWare 7's C++ compiler is the same:
"a.C", line 11: error: initial value of reference to non-const must be an lvalue
      func((int)val);
           ^

Kean.


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