public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jason at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/15795] No way to teach operator new anything about alignment requirements
Date: Tue, 08 Jun 2004 20:04:00 -0000	[thread overview]
Message-ID: <20040608200416.23276.qmail@sourceware.org> (raw)
In-Reply-To: <20040603143635.15795.ma1flfs@bath.ac.uk>


------- Additional Comments From jason at redhat dot com  2004-06-08 20:04 -------
Subject: Re:  No way to teach operator new anything about
 alignment requirements

On 8 Jun 2004 19:25:27 -0000, "bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> wrote:

> 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.

I don't think it would actually be a problem, since enums are distinct
types.  But I understand your concern, since they do promote to integers,
and I'm not opposed to using a struct instead.

> Having something like 
>   template <int> struct Alignment {}; 
>   template <int N> operator new (size_t, Alignment<N>); 

Or

template <typename T> struct Alignment
{
  static const size_t alignment = __alignof (T);
};
template <typename T> inline void *
operator new (size_t size, Alignment<T> align)
{
  return align_new (size, align.alignment);
}

...
new (Alignment<Vector4>) Vector4[200];

Yes, that seems like a cleaner syntax for explicit placement new.

> 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... ;-) 

I'm not familiar with SFINAE.

Jason


-- 


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


  parent reply	other threads:[~2004-06-08 20:04 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-03 14:36 [Bug c++/15795] New: Strange bug / incorrect code generation with SSE ma1flfs at bath dot ac dot uk
2004-06-03 14:50 ` [Bug c++/15795] " pinskia at gcc dot gnu dot org
2004-06-03 14:54 ` ma1flfs at bath dot ac dot uk
2004-06-03 14:57 ` pinskia at gcc dot gnu dot org
2004-06-03 15:09 ` ma1flfs at bath dot ac dot uk
2004-06-03 15:12 ` pinskia at gcc dot gnu dot org
2004-06-03 15:15 ` ma1flfs at bath dot ac dot uk
2004-06-03 15:18 ` pinskia at gcc dot gnu dot org
2004-06-03 16:25 ` ma1flfs at bath dot ac dot uk
2004-06-03 17:08 ` ma1flfs at bath dot ac dot uk
2004-06-03 17:18   ` Andrew Pinski
2004-06-03 17:18 ` pinskia at physics dot uc dot edu
2004-06-03 17:33 ` bangerth at dealii dot org
2004-06-03 17:39 ` [Bug c++/15795] No way to teach operator new anything about alignment requirements bangerth at dealii dot org
2004-06-03 22:40 ` pinskia at gcc dot gnu dot org
2004-06-03 23:02 ` jason at gcc dot gnu dot org
2004-06-04  0:15 ` bangerth at dealii dot org
2004-06-04  9:34 ` ma1flfs at bath dot ac dot uk
2004-06-04 11:29 ` nathan at gcc dot gnu dot org
2004-06-04 13:42 ` bangerth at dealii dot org
2004-06-05 14:28 ` ma1flfs at bath dot ac dot uk
2004-06-08 15:56 ` bangerth at dealii dot org
2004-06-08 16:43 ` nathan at gcc dot gnu dot org
2004-06-08 17:43 ` bangerth at dealii dot org
2004-06-08 18:04 ` jason at gcc dot gnu dot org
2004-06-08 18:05 ` jason at redhat dot com
2004-06-08 18:39 ` jason at redhat dot com
2004-06-08 18:45 ` ma1flfs at bath dot ac dot uk
2004-06-08 19:04 ` jason at redhat dot com
2004-06-08 19:25 ` bangerth at dealii dot org
2004-06-08 19:27 ` ma1flfs at bath dot ac dot uk
2004-06-08 20:04 ` jason at redhat dot com [this message]
2004-06-08 20:06 ` jason at redhat dot com
2004-06-08 20:26 ` ma1flfs at bath dot ac dot uk
2004-06-08 20:34 ` jakub at gcc dot gnu dot org
2004-06-08 20:45 ` bangerth at dealii dot org
2004-07-15  4:33 ` pinskia at gcc dot gnu dot org
2005-01-13 23:21 ` pinskia at gcc dot gnu dot org
     [not found] <bug-15795-6844@http.gcc.gnu.org/bugzilla/>
2006-10-10  4:54 ` mrs at apple dot com
2006-11-12 15:33 ` timday at bottlenose dot demon dot co dot uk
2008-11-10 22:35 ` pinskia at gcc dot gnu dot org
2008-11-11  6:25 ` David dot Monniaux at imag dot fr
2008-11-20 16:45 ` hjl dot tools at gmail dot com
2008-12-09 17:56 ` rguenth at gcc dot gnu dot org
     [not found] <bug-15795-4@http.gcc.gnu.org/bugzilla/>
2021-10-29  1:01 ` pinskia at gcc dot gnu.org
2021-10-30 10:39 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040608200416.23276.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).