Discussion:
reference binding
(too old to reply)
Fraser Ross
2008-07-24 19:50:07 UTC
Permalink
With BDS2006 there is not a diagnostic for this or similar code:

class D { };

D d;
D & dr ( static_cast<D const &>(d) );

Fraser.
Sergiy Kanilo
2008-07-24 21:27:38 UTC
Permalink
Post by Fraser Ross
class D { };
D d;
D & dr ( static_cast<D const &>(d) );
Fraser.
I believe this pre-standard behavior was supported since the first
Borland C++ compiler.

CG2007 gives

[BCC32 Warning] File1.cpp(4): W8028 Temporary used to initialize 'dr'

in Borland compliance mode and

[BCC32 Error] File1.cpp(4): E2034 Cannot convert 'const D' to 'D &'
[BCC32 Warning] File1.cpp(4): W8028 Temporary used to initialize 'dr'

in Ansi compliance mode (IMHO the BDS2006 should give the same error in
Ansi compliance mode too).

Cheers,
Serge

Loading...