public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "law at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/59083] -fisolate-erroneous-paths produces illegal instruction with enabled -fprofile-generate
Date: Wed, 13 Nov 2013 16:50:00 -0000	[thread overview]
Message-ID: <bug-59083-4-pDRxGmRYpY@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-59083-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #17 from Jeffrey A. Law <law at redhat dot com> ---
Markus,

For the kernel case, note the qsort prototype and the non-null attribute.  That
explicitly states that the pointer arguments must not be null.  Any code which
then passes null for those arguments has stepped into the realm of undefined
behaviour.

Prior to CCP2 we have:

main ()
{
  int * _3;

;;   basic block 2, loop depth 0, count 0, freq 10000, maybe hot
;;    prev block 0, next block 1, flags: (NEW, REACHABLE)
;;    pred:       ENTRY [100.0%]  (FALLTHRU,EXECUTABLE)
  _3 = a.offset;
  qsort (_3, 0);
  return 0;
;;    succ:       EXIT [100.0%]

}

a.offset gets folded to zero by CCP2 resulting in:
main ()
{
;;   basic block 2, loop depth 0, count 0, freq 10000, maybe hot
;;    prev block 0, next block 1, flags: (NEW, REACHABLE)
;;    pred:       ENTRY [100.0%]  (FALLTHRU,EXECUTABLE)
  qsort (0B, 0);
  return 0;
;;    succ:       EXIT [100.0%]

}

Note we're passing NULL as the first argument to qsort, which has a declaration
saying that none of its pointer arguments can be NULL.  

Note we're able to fold a.offset to zero because we can see "a"'s initializer. 

AFAICT the code is doing exactly what is expected.


  parent reply	other threads:[~2013-11-13 16:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-11 22:04 [Bug c++/59083] New: " marxin.liska at gmail dot com
2013-11-11 22:50 ` [Bug c++/59083] " law at redhat dot com
2013-11-12 16:00 ` marxin.liska at gmail dot com
2013-11-12 16:17 ` octoploid at yandex dot com
2013-11-12 16:19 ` law at redhat dot com
2013-11-12 16:26 ` octoploid at yandex dot com
2013-11-12 16:39 ` octoploid at yandex dot com
2013-11-12 23:10 ` law at redhat dot com
2013-11-13  5:17 ` octoploid at yandex dot com
2013-11-13  5:30 ` law at redhat dot com
2013-11-13  7:34 ` law at redhat dot com
2013-11-13  7:42 ` law at redhat dot com
2013-11-13  7:50 ` octoploid at yandex dot com
2013-11-13  9:08 ` octoploid at yandex dot com
2013-11-13 15:47 ` rguenth at gcc dot gnu.org
2013-11-13 16:50 ` law at redhat dot com [this message]
2013-11-13 17:04 ` octoploid at yandex dot com
2013-11-13 17:10 ` law at redhat dot com
2013-11-18 12:03 ` octoploid at yandex dot com
2013-12-18 13:08 ` trippels 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=bug-59083-4-pDRxGmRYpY@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).