Re: Copy constructor: inconsistency across compilers
h.yuzhao@gmail.com wrote:
:: On Jun 21, 3:50 am, Hyman Rosen <hyro...@mail.com> wrote:
::: Thomas Mang wrote:
::::: Hyman Rosen wrote:
::::: There may already be some compilers that implement this.
:::
:::: My impression is it's the other way around ... "taking
:::: advantage" ... of this compiler-loophole has been relatively
:::: frequent.
:::
::: Yes. I meant that some compilers now know that with the proposed
::: wording the binding must be direct and therefore they must not
::: check accessibility of the copy constructor, as opposed to being
::: required to check with the old wording in place.
:::
::
:: MSVC8 won't check the copy ctor. The copy ctor is not neccesary in
:: such case because it is not get invoked. I think it may be
:: optimized as NRV which means there is no need to create an
:: instance on parameter stack but pass the reference instead.
:: So, the copy ctor is useless.
::
It does check the rules, if you just select the "Disable Language
Extensions" options in the projects settings.
Microsofts "extensions" includes allowing lots of pre-standard code,
like binding temporaries to a non-const reference, and allowing
strange loop variable scopes. It also obviously allows the use of a
private copy constructor - if it is optimized away.
Please try the /Za option when testing code for conformance!
Bo Persson
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]