This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

semantics of attribute const on constructors


Hi,

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 
e.g.
Foo a(1);
Foo b(1);
, 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? :-)

Cheers,
	Matthias

-- 
Dipl.-Phys. Matthias Kretz
http://compeng.uni-frankfurt.de/index.php?id=mkretz


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]