public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Marek Polacek <polacek@redhat.com>
Cc: "Joseph S. Myers" <joseph@codesourcery.com>,
	       GCC Patches <gcc-patches@gcc.gnu.org>,
	       Richard Biener <rguenther@suse.de>,
	Jason Merrill <jason@redhat.com>
Subject: Re: [C PATCH] Disallow subtracting pointers to empty structs (PR c/58346)
Date: Wed, 15 Jan 2014 10:35:00 -0000	[thread overview]
Message-ID: <20140115103540.GY892@tucnak.redhat.com> (raw)
In-Reply-To: <20140115102737.GJ4458@redhat.com>

On Wed, Jan 15, 2014 at 11:27:37AM +0100, Marek Polacek wrote:
> Perhaps, but I don't think we can do it easily.  Consider
> 
> int
> foo (int *p, int *q)
> {
>   return p - q;
> }

That is not a difference of pointers to zero sized arrays though,
that is pointers to int, and there is no division by zero involved, you can
get 0 as the result of course.

I think Joseph meant say

__PTRDIFF_TYPE__
foo (int p[3][0], int q[3][0])
{
  return p - q;
}

which is also (((long int) p - (long int) q) /[ex] 0).

	Jakub

  reply	other threads:[~2014-01-15 10:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-13 16:32 Marek Polacek
2014-01-13 17:21 ` Florian Weimer
2014-01-13 17:22 ` Marek Polacek
2014-01-13 20:48   ` Marek Polacek
2014-01-14 14:39     ` Jason Merrill
2014-01-14 17:52     ` Florian Weimer
2014-01-15  9:12       ` Marek Polacek
2014-01-14 21:42     ` Joseph S. Myers
2014-01-15 10:27       ` Marek Polacek
2014-01-15 10:35         ` Jakub Jelinek [this message]
2014-01-15 13:50           ` Marek Polacek
2014-01-15 21:23             ` Joseph S. Myers
2014-01-16 18:52               ` Marek Polacek
2014-01-23  9:15                 ` Marek Polacek
2014-01-23 17:47                   ` Joseph S. Myers
2014-01-16 11:50             ` Eric Botcazou
2014-01-16 11:58               ` Marek Polacek

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=20140115103540.GY892@tucnak.redhat.com \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=polacek@redhat.com \
    --cc=rguenther@suse.de \
    /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).