public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ian at g0tcd dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/59933] for loop goes wild with assert() enabled
Date: Thu, 20 Feb 2014 01:00:00 -0000	[thread overview]
Message-ID: <bug-59933-4-zYNbNSoeja@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-59933-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #13 from Ian Hamilton <ian at g0tcd dot com> ---
(In reply to Mark Warner from comment #11)
> I'm confused .. what about..
> for (k = i; k < (int)(sizeof(NSQ_del_dec_struct) / sizeof(opus_int32)); ++k)
> ... is illegal or invalid ?
> Why does it only fail if -DDEBUG is defined ?
> I mean, this code worked fine for months .. and now

What this code seems to be doing is copying a section at the end of the
sLPC_Q14 array at the beginning of the NSQ_del_dec_struct structure, plus all
the other structure members that follow the array (RandState[32], Q_Q10[32],
etc.).

It is doing this by deliberately running the sLPC_Q14 array index beyond the
end of the array, i.e. it is RELYING on undefined behaviour.

I'd have said your work-around solution is actually the better code.


      parent reply	other threads:[~2014-02-20  1:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-24 12:56 [Bug c/59933] New: " warnerme at ptd dot net
2014-01-24 13:00 ` [Bug c/59933] " warnerme at ptd dot net
2014-01-29 12:25 ` ian at g0tcd dot com
2014-01-29 13:14 ` ian at g0tcd dot com
2014-02-19  8:36 ` mpolacek at gcc dot gnu.org
2014-02-19 12:27 ` warnerme at ptd dot net
2014-02-19 14:08 ` warnerme at ptd dot net
2014-02-19 14:54 ` mpolacek at gcc dot gnu.org
2014-02-19 15:49 ` jakub at gcc dot gnu.org
2014-02-19 16:12 ` ian at g0tcd dot com
2014-02-19 16:41 ` jakub at gcc dot gnu.org
2014-02-19 20:57 ` jakub at gcc dot gnu.org
2014-02-20  1:00 ` ian at g0tcd dot com [this message]

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-59933-4-zYNbNSoeja@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).