public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason_merrill@redhat.com>
To: kenner@vlsi1.ultra.nyu.edu (Richard Kenner)
Cc: law@cygnus.com, gcc@gcc.gnu.org, jason_merrill@redhat.com
Subject: Re: Added error message (for too-large array)
Date: Tue, 25 Sep 2001 04:52:00 -0000	[thread overview]
Message-ID: <m3d74flc9m.fsf@prospero.cambridge.redhat.com> (raw)
In-Reply-To: <10109111102.AA21306@vlsi1.ultra.nyu.edu>

>>>>> "Richard" == Richard Kenner <kenner@vlsi1.ultra.nyu.edu> writes:

> What was the purpose of adding an error message in layout_type when an
> array's size cannot be represented in size_t?

If the size cannot be represented in size_t, it isn't represented
internally in gcc in any useful way; it overflows to some number bearing
little relation to what the user intended.

Now I notice that the C frontend already caught this, in grokdeclarator.  I
suppose the C++ frontend could handle it similarly, but I didn't see how a
type too large to represent could be useful for any language.

> We should give an error if the size of an *object* can't be
> representable, but why a type?

I suppose that moving the test for overflowing TYPE_SIZE to layout_decl
would be plausible.

> Note that you don't check for RECORD_TYPE, just ARRAY_TYPE.

I suppose that would make sense for completeness, though the problem is
much less likely there.

> It's a fairly common idiom in Ada to make an array type whose bounds
> are all integers to represent "all memory".  If it's an array of bytes
> that's OK, but not if it's an array of anything wider.  So this error
> causes problems there.

It would think the Ada frontend should set TYPE_SIZE itself for such an
ARRAY_TYPE, rather than let the middle-end come up with a meaningless
value.

Jason

  reply	other threads:[~2001-09-25  4:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-11  3:57 Added error message Richard Kenner
2001-09-25  4:52 ` Jason Merrill [this message]
2001-09-25  5:41 Added error message (for too-large array) Richard Kenner
2001-09-25  6:23 ` Jason Merrill
2001-09-25  6:30 dewar
2001-09-25  6:39 ` Jason Merrill
2001-09-25  7:05 Richard Kenner
2001-09-25  7:05 dewar

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=m3d74flc9m.fsf@prospero.cambridge.redhat.com \
    --to=jason_merrill@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=kenner@vlsi1.ultra.nyu.edu \
    --cc=law@cygnus.com \
    /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).