public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/1833: [2003-01-01] inlining sometimes causes incorrect behavior
@ 2003-05-08 23:26 Giovanni Bajo
0 siblings, 0 replies; 2+ messages in thread
From: Giovanni Bajo @ 2003-05-08 23:26 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c++/1833; it has been noted by GNATS.
From: "Giovanni Bajo" <giovannibajo@libero.it>
To: <gcc-gnats@gcc.gnu.org>,
<gcc-bugs@gcc.gnu.org>,
<nobody@gcc.gnu.org>,
<gcc-prs@gcc.gnu.org>,
<peteb@sitera.com>
Cc:
Subject: Re: c++/1833: [2003-01-01] inlining sometimes causes incorrect behavior
Date: Fri, 9 May 2003 01:17:04 +0200
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=1833
Given Alexander's analysys, which I confirm, this PR boils down to the
following code:
--------------------------------
typedef char *pchar;
void func(pchar &s)
{}
int main ()
{
char *s = "123";
func((pchar)s);
}
--------------------------------
which is illegal, because the cast creates a temporary rvalue which cannot
be bound to a non-const reference. But GCC compiles it happily even
with -ansi -pedantic. So it's an accept-illegal.
Giovanni Bajo
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: c++/1833: [2003-01-01] inlining sometimes causes incorrect behavior
@ 2003-04-03 17:26 Nigel Stewart
0 siblings, 0 replies; 2+ messages in thread
From: Nigel Stewart @ 2003-04-03 17:26 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c++/1833; it has been noted by GNATS.
From: Nigel Stewart <nigels@nigels.com>
To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org,
gcc-prs@gcc.gnu.org, peteb@sitera.com
Cc:
Subject: Re: c++/1833: [2003-01-01] inlining sometimes causes incorrect behavior
Date: Fri, 04 Apr 2003 03:24:48 +1000
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=1833
Perhaps the bug/problem/issue I've found in gcc is related to this one
already in the database: Problem Report 1833
-------
#include <iostream>
using namespace std;
float foo()
{
assert(sizeof(unsigned int)==sizeof(float));
float tmp = 0.0;
*((unsigned int *) &tmp) = (127<<23) | (1<<22);
return tmp;
}
int main(int argc,char *argv[])
{
cout << "Output should be 1.5: " << foo() << endl;
}
-------
$ gcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.2/specs
Configured with: /netrel/src/gcc-3.2-3/configure --enable-languages=c,c++,f77,java --enable-libgcj --enable-threads=posix --with-system-zlib --enable-nls --without-included-gettext --enable-interpreter --disable-sjlj-exceptions --disable-version-specific-runtime-libs --enable-shared --build=i686-pc-linux --host=i686-pc-cygwin --target=i686-pc-cygwin --enable-haifa --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --includedir=/nonexistent/include --libexecdir=/usr/sbin
Thread model: posix
gcc version 3.2 20020927 (prerelease)
$ g++ test.cpp -o test && ./test
Output should be 1.5: 1.5
$ g++ -O2 test.cpp -o test && ./test
Output should be 1.5: 0
--------
The following version of foo does not exhibit the same problem:
float foo()
{
assert(sizeof(unsigned int)==sizeof(float));
unsigned int tmp = (127<<23) | (1<<22);
return *((float *) &tmp);
}
Regards,
Nigel Stewart
nigels@nigels.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-05-08 23:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-08 23:26 c++/1833: [2003-01-01] inlining sometimes causes incorrect behavior Giovanni Bajo
-- strict thread matches above, loose matches on Subject: below --
2003-04-03 17:26 Nigel Stewart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).