This is the mail archive of the
mailing list for the GCC project.
semantics of attribute const on constructors
- From: Matthias Kretz <kretz at compeng dot uni-frankfurt dot de>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 25 Feb 2011 16:19:22 +0100
- Subject: semantics of attribute const on constructors
what are the exact semantics of __attribute__((const)), when attached to a C++
class constructor, supposed to be?
My expectation was, that, since the ctor has a constructed object as return
value, the compiler is free, instead of calling a ctor twice for the case of
, to do a memcopy of a to b after the a ctor is done.
Instead the result of using __attribute__((const)) is, that GCC feels free to
optimize the whole ctor away. Apparently the ctor is treated as a function
that returns void.
Do you rather want a bug report for the website documenting attribute const,
or for how GCC implements it? :-)
Dipl.-Phys. Matthias Kretz