This is the mail archive of the gcc-help@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]

Is avoding calling default constructor possible?


Hi,

Is it possible to create array of objects T without calling the
default constructors T::T() ?
Calling other constructor instead would be great.
Leaving the memory uninitalize is ok as well, as I can do placement new later.

I want to avoid char* casting to T* because it breaks strict aliasing rules
(stopping optimizations from happening and slowing my program by 25%.)

Answer to this question would provide walkaround to the aliasing
problem I described few days ago.

Thanks in advance for any ideas
Lukasz Lew


PS
Manual says that uinon is the way to go with strict-aliasing, but unfortunately:

union {
  char tab [N * sizeof(Elt)];
  Elt tab2 [N];
};

Doesn't compile because Elt *has* default constructor.


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