public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ebotcazou at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/56474] [4.8 regression] bogus Storage_Error raised for record containing empty zero-based array Date: Mon, 04 Mar 2013 11:29:00 -0000 [thread overview] Message-ID: <bug-56474-4-xGCzZLT3O2@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-56474-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56474 --- Comment #7 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2013-03-04 11:29:16 UTC --- > What will the result be used for in this case? The result, usizetype_max, > is certainly not 0 - 1 == -1 as it is unsigned. It's used for the upper bound of variable-sized arrays: /* Finally we use (hb >= lb) ? hb : lb - 1 for the upper bound in all the other cases. Note that, here as well as above, the condition used in the comparison must be equivalent to the condition (length != 0). This is relied upon in order to optimize array comparisons in compare_arrays. */ else gnu_high = build_cond_expr (sizetype, build_binary_op (GE_EXPR, boolean_type_node, gnu_orig_max, gnu_orig_min), gnu_max, size_binop (MINUS_EXPR, gnu_min, size_one_node)); The result wraps around but that's fine; we just don't want the overflow. > Adding kludges like that might work, but I'd rather try to fix callers > to "ask more intelligent questions". That is, > > + /* ??? We make an exception for 0 - 1 because it's an idiom > + used in length calculations for zero-based arrays. */ > + if (integer_zerop (arg0) && integer_onep (arg1)) > + overflowable = 1; > > the length of an array is max-index - min-index + 1. What's the call > stack of this testcases case triggering the overflow? Yes, the formula for the upper bound is designed to yield a length of zero if the upper bound is lower than the lower bound. size_binop is called from ada/gcc-interface/decl.c:gnat_to_gnu_entity.
next prev parent reply other threads:[~2013-03-04 11:29 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-02-27 17:41 [Bug ada/56474] New: GNAT computes size of the object to be allocated incorrectly pavel at zhukoff dot net 2013-02-28 11:02 ` [Bug ada/56474] [4.8 regression] bogus Storage_Error raised for record containing empty zero-based array ebotcazou at gcc dot gnu.org 2013-02-28 11:04 ` ebotcazou at gcc dot gnu.org 2013-03-01 11:28 ` rguenth at gcc dot gnu.org 2013-03-01 14:26 ` ebotcazou at gcc dot gnu.org 2013-03-01 14:33 ` [Bug middle-end/56474] " ebotcazou at gcc dot gnu.org 2013-03-04 9:53 ` rguenth at gcc dot gnu.org 2013-03-04 11:29 ` ebotcazou at gcc dot gnu.org [this message] 2013-03-04 15:12 ` rguenther at suse dot de 2013-03-04 15:39 ` ebotcazou at gcc dot gnu.org 2013-03-04 15:45 ` rguenther at suse dot de 2013-03-04 15:51 ` jakub at gcc dot gnu.org 2013-03-04 16:19 ` ebotcazou at gcc dot gnu.org 2013-03-05 9:05 ` rguenther at suse dot de 2013-03-06 17:21 ` ebotcazou at gcc dot gnu.org 2013-03-07 11:37 ` jakub at gcc dot gnu.org 2013-03-22 14:42 ` [Bug middle-end/56474] [4.8/4.9 " jakub at gcc dot gnu.org 2013-05-06 9:34 ` ebotcazou at gcc dot gnu.org 2013-05-07 7:50 ` [Bug ada/56474] " ebotcazou at gcc dot gnu.org 2013-05-07 8:07 ` ebotcazou at gcc dot gnu.org 2013-05-07 8:07 ` ebotcazou at gcc dot gnu.org 2013-05-07 8:08 ` ebotcazou 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-56474-4-xGCzZLT3O2@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: linkBe 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).