From mboxrd@z Thu Jan 1 00:00:00 1970 From: aoliva@gcc.gnu.org To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org Subject: Re: c++/1833 Date: Sun, 01 Apr 2001 00:00:00 -0000 Message-id: <20010302103601.25213.qmail@sourceware.cygnus.com> X-SW-Source: 2001-q1/msg01871.html List-Id: The following reply was made to PR c++/1833; it has been noted by GNATS. From: aoliva@gcc.gnu.org To: gcc-gnats@gcc.gnu.org, nobody@gcc.gnu.org, peteb@sitera.com Cc: Subject: Re: c++/1833 Date: 2 Mar 2001 10:26:28 -0000 Synopsis: inlining sometimes causes incorrect behavior State-Changed-From-To: open->analyzed State-Changed-By: aoliva State-Changed-When: Fri Mar 2 02:26:28 2001 State-Changed-Why: There is indeed a bug. The problem is that the result of the cast is an rvalue, because the cast-to type is not a reference type. Therefore, a temporary should be created. However, a temporary cannot be bound to a non-const reference, but g++ happily binds it to frob2's argument, even with -ansi -pedantic. Even if the binding-to-non-const were to be done as an extension, it still shouldn't modify variable s; it should modify the temporary, then discard it. WRT the difference between the inline and the non-inline functions, the problem is likely to be in the tree level, because the initial RTL dump is already significantly different for the two functions. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=1833&database=gcc