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

[Bug c++/15795] No way to teach operator new anything about alignment requirements


------- Additional Comments From bangerth at dealii dot org  2004-06-08 19:25 -------
I we are to provide a workaround, I think that the signature you 
propose, i.e. 
  operator new (size_t size, enum align_tag, size_t align); 
may not be a good idea, the second and third argument being an integer. This 
is just way too common and asking for trouble. Why not 
  struct AlignTag { 
    AlignTag (int alignment); 
    //... 
  }; 
 
  operator new (size_t, AlignTag) 
 
and convert 
  new Vector4[200]; 
into 
  new (__gnu_cxx::AlignTag(__alignof (Vector4)) Vector4[200]; 
 
Having something like 
  template <int> struct Alignment {}; 
  template <int N> operator new (size_t, Alignment<N>); 
may also be a neat possibility if we use SFINAE to provide  
  template <int N> 
  typename SFINAE<(N<=STD_ALIGNMENT),void*> operator new (size_t,Alignment<T>) 
and the opposite case as two overloads, and let the compiler pick which  
one it wants to call. This way we can switch at compile time which allocation 
function shall be called. But I think I'm carried away... ;-) 
 
W. 
 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15795


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