Article View: gnu.gcc.bug
Article #6044Bug in gcc 2.7.2 on platform alpha-dec-osf3.2
From: Randy Smith
Date: Tue, 10 Dec 1996 00:00
Date: Tue, 10 Dec 1996 00:00
64 lines
1896 bytes
1896 bytes
Compiling the following file:
----------
class A {
public:
A();
int y;
char c;
};
class B {
public:
B();
char a, b;
};
main(int argc, char **argv)
{
A a;
B &b = static_cast<B&>(a);
}
----------
with the command line:
g++ -c test.cc
for gcc 2.7.2 on platform alpha-dec-osf3.2:
$ g++ -v
gcc -v
Reading specs from /usr/local/gnu/lib/gcc-lib/alpha-dec-osf3.2/2.7.2/specs
gcc version 2.7.2
does *not* produce any error messages, where I believe that it
should. Quoting from Ellis&Stroustrup, _The Annotated C++ Reference
Manual_, page 414, ANSI/ISO Resolutions section $5.2.4:
static_cast<T>(e) casts e to a T exactly as (T)e would have done
provided there is an implicit conversion from T to the type of e of
an implicit conversion from the type of e to T. Otherwise,
static_cast<T>(e) is an error.
This looks like a bug to me, but I would also welcome someone
explaining to me why it isn't. I replaced the static cast with a
direct assignment, and that produced errors, implying that there is
at least no implicit conversion from A-->B.
This problem has also been noted (in a substantantially more
complicated example) in a gcc 2.7.1 cross compiler from
alpha->i386. In that more complicated example, I verified that
there was also no implict conversion from B-->A.
-- Randy
Technical Details
Message-ID:
<9612102059.AA03747@mordor.osf.org>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 113d02,8d0d9ab0725227ef,start X-Google-Attributes: gid113d02,public From: randys@osf.org (Randy Smith) Subject: Bug in gcc 2.7.2 on platform alpha-dec-osf3.2 Date: 1996/12/10 Message-ID: <9612102059.AA03747@mordor.osf.org> X-Deja-AN: 203413162 sender: bug-gcc-request@prep.ai.mit.edu x-gateway: relay5.UU.NET from bug-gcc to gnu.gcc.bug; Tue, 10 Dec 1996 19:59:26 EST newsgroups: gnu.gcc.bug