public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: bkoz@gcc.gnu.org
To: gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org,
	wesslen@users.sourceforge.net
Subject: Re: libstdc++/6732: misaligned objects created by new
Date: Wed, 03 Jul 2002 22:51:00 -0000	[thread overview]
Message-ID: <20020704055150.16219.qmail@sources.redhat.com> (raw)

Synopsis: misaligned objects created by new

State-Changed-From-To: open->analyzed
State-Changed-By: bkoz
State-Changed-When: Wed Jul  3 22:51:48 2002
State-Changed-Why:
    I'm not quite convinced that this is a C++ library problem.
    It seems like "C" also has the same issue. 
    
    Note that gcc-2.96, others also have the same behavior.
    
    
    #include <iostream>
     
    struct vec4 
    {
      float x, y, z, w;
    } __attribute__((__aligned__(16)));
    
    int main()
    {
      std::allocator<vec4> a;
      
      for (int i = 0; i < 10; ++i) 
        {
          vec4* p = new vec4;
          std::cerr << reinterpret_cast<void*>(p) << " ";
          std::cerr << reinterpret_cast<std::size_t>(p) % 16 << " ";
          std::cerr << std::endl;
        }
    
      for (int i = 0; i < 10; ++i) 
        {
          vec4* p = reinterpret_cast<vec4*>(malloc(sizeof(vec4)));
          std::cerr << reinterpret_cast<void*>(p) << " ";
          std::cerr << reinterpret_cast<std::size_t>(p) % 16 << " ";
          std::cerr << std::endl;
        }
    }
    

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6732


             reply	other threads:[~2002-07-04  5:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-03 22:51 bkoz [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-08-03 13:46 Gabriel Dos Reis
2002-08-03 13:27 bkoz
2002-05-27  5:36 bkoz
2002-05-20  5:46 Daniel Wesslén
2002-05-20  5:21 paolo
2002-05-20  5:16 wesslen

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=20020704055150.16219.qmail@sources.redhat.com \
    --to=bkoz@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@gcc.gnu.org \
    --cc=wesslen@users.sourceforge.net \
    /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).