public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "trippels at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/66230] Using optimizations causes program to segfault
Date: Thu, 21 May 2015 11:26:00 -0000	[thread overview]
Message-ID: <bug-66230-4-h398SpkQl8@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-66230-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66230

--- Comment #10 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
(In reply to gpnuma from comment #8)
> Thanks Markus I didn't think these alignment issues were actually the
> problem, it goes a long way.
> 
> By doing memmoves instead of pointer cast allocations I got rid of the
> segfault, but of course things are much slower... this "undefined behaviour"
> is really treacherous !!
> 
> Is there any way to ensure proper alignment so I don't fall into this trap
> and still benefit from maximum speed ?

I'm afraid there is no general recipe that would ensure proper alignment.
But using memcpy hasn't necessary to be "much slower".
And trading undefined behavior for a little more speed isn't a good idea in
general.


  parent reply	other threads:[~2015-05-21 11:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-66230-4@http.gcc.gnu.org/bugzilla/>
2015-05-21  6:03 ` trippels at gcc dot gnu.org
2015-05-21  9:32 ` gpnuma at centaurean dot com
2015-05-21  9:55 ` gpnuma at centaurean dot com
2015-05-21 10:04 ` gpnuma at centaurean dot com
2015-05-21 10:16 ` trippels at gcc dot gnu.org
2015-05-21 10:32 ` gpnuma at centaurean dot com
2015-05-21 10:35 ` gpnuma at centaurean dot com
2015-05-21 11:26 ` trippels at gcc dot gnu.org [this message]
2015-05-21 15:53 ` gpnuma at centaurean dot com

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=bug-66230-4-h398SpkQl8@http.gcc.gnu.org/bugzilla/ \
    --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).