This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++ bug (references)
- To: Joe Buck <jbuck at synopsys dot com>, Sam Lantinga <slouken at devolution dot com>
- Subject: Re: C++ bug (references)
- From: "J. Kean Johnston" <jkj at sco dot com>
- Date: Fri, 26 Feb 1999 11:53:07 -0800
- Cc: egcs at egcs dot cygnus dot com, highlander at lokigames dot com
- Organization: The Santa Cruz Operation, Inc.
- References: <E10GRON-0001t5-00@roboto.devolution.com> <199902261808.KAA16750@atrus.synopsys.com>
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.