From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29594 invoked by alias); 8 Jun 2004 19:25:27 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 29498 invoked by uid 48); 8 Jun 2004 19:25:26 -0000 Date: Tue, 08 Jun 2004 19:25:00 -0000 Message-ID: <20040608192525.29497.qmail@sourceware.org> From: "bangerth at dealii dot org" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20040603143635.15795.ma1flfs@bath.ac.uk> References: <20040603143635.15795.ma1flfs@bath.ac.uk> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/15795] No way to teach operator new anything about alignment requirements X-Bugzilla-Reason: CC X-SW-Source: 2004-06/txt/msg00972.txt.bz2 List-Id: ------- 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 struct Alignment {}; template operator new (size_t, Alignment); may also be a neat possibility if we use SFINAE to provide template typename SFINAE<(N<=STD_ALIGNMENT),void*> operator new (size_t,Alignment) 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