On Thu, 23 Jan 2014, Marek Polacek wrote:
> > 2014-01-16 Marek Polacek
> >
> > PR c/58346
> > c-family/
> > * c-common.c (pointer_to_zero_sized_aggr_p): New function.
> > * c-common.h: Declare it.
> > cp/
> > * typeck.c (pointer_diff): Give an error on arithmetic on pointer to
Ping.
On Thu, Jan 16, 2014 at 07:52:43PM +0100, Marek Polacek wrote:
> On Wed, Jan 15, 2014 at 09:23:06PM +, Joseph S. Myers wrote:
> > On Wed, 15 Jan 2014, Marek Polacek wrote:
> >
> > > +/* Return true if T is a pointer to a zero-sized struct/union. */
> > > +
> > > +bool
> > > +pointer_to
On Wed, Jan 15, 2014 at 09:23:06PM +, Joseph S. Myers wrote:
> On Wed, 15 Jan 2014, Marek Polacek wrote:
>
> > +/* Return true if T is a pointer to a zero-sized struct/union. */
> > +
> > +bool
> > +pointer_to_zero_sized_aggr_p (tree t)
> > +{
> > + t = strip_pointer_operator (t);
> > + ret
On Thu, Jan 16, 2014 at 12:50:10PM +0100, Eric Botcazou wrote:
> > +/* Return true if T is a pointer to a zero-sized struct/union. */
> > +
> > +bool
> > +pointer_to_zero_sized_aggr_p (tree t)
> > +{
> > + t = strip_pointer_operator (t);
> > + return ((RECORD_OR_UNION_TYPE_P (t) || TREE_CODE (t)
> +/* Return true if T is a pointer to a zero-sized struct/union. */
> +
> +bool
> +pointer_to_zero_sized_aggr_p (tree t)
> +{
> + t = strip_pointer_operator (t);
> + return ((RECORD_OR_UNION_TYPE_P (t) || TREE_CODE (t) == ARRAY_TYPE)
> + && TYPE_SIZE (t)
> + && integer_zerop (TYPE_S
On Wed, 15 Jan 2014, Marek Polacek wrote:
> +/* Return true if T is a pointer to a zero-sized struct/union. */
> +
> +bool
> +pointer_to_zero_sized_aggr_p (tree t)
> +{
> + t = strip_pointer_operator (t);
> + return ((RECORD_OR_UNION_TYPE_P (t) || TREE_CODE (t) == ARRAY_TYPE)
> + && TYPE_
On Wed, Jan 15, 2014 at 11:35:40AM +0100, Jakub Jelinek wrote:
> 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 pointe
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 b
On Tue, Jan 14, 2014 at 09:42:37PM +, Joseph S. Myers wrote:
> On Mon, 13 Jan 2014, Marek Polacek wrote:
>
> > +/* Return true if T is a pointer to a zero-sized struct/union. */
> > +
> > +bool
> > +pointer_to_zero_sized_aggr_p (tree t)
> > +{
> > + t = strip_pointer_operator (t);
> > + if
On Tue, Jan 14, 2014 at 06:52:00PM +0100, Florian Weimer wrote:
> On 01/13/2014 09:48 PM, Marek Polacek wrote:
> >+bool
> >+pointer_to_zero_sized_aggr_p (tree t)
> >+{
> >+ t = strip_pointer_operator (t);
> >+ if (RECORD_OR_UNION_TYPE_P (t)
> >+ && TYPE_SIZE (t)
> >+ && integer_zerop (T
On Mon, 13 Jan 2014, Marek Polacek wrote:
> +/* Return true if T is a pointer to a zero-sized struct/union. */
> +
> +bool
> +pointer_to_zero_sized_aggr_p (tree t)
> +{
> + t = strip_pointer_operator (t);
> + if (RECORD_OR_UNION_TYPE_P (t)
> + && TYPE_SIZE (t)
> + && integer_zerop (TY
On 01/13/2014 09:48 PM, Marek Polacek wrote:
+bool
+pointer_to_zero_sized_aggr_p (tree t)
+{
+ t = strip_pointer_operator (t);
+ if (RECORD_OR_UNION_TYPE_P (t)
+ && TYPE_SIZE (t)
+ && integer_zerop (TYPE_SIZE (t)))
+return true;
+ return false;
+}
I think you can just return th
The C++ part is OK.
Jason
On Mon, Jan 13, 2014 at 05:48:59PM +0100, Marek Polacek wrote:
> The patch will need some tweaking, I realized that e.g. for struct S {
> union {}; }; it doesn't do the right thing...
Done in the patch below. CCing Jason for the C++ part. Does this
look sane now?
Regtested/bootstrapped on x86_6
On Mon, Jan 13, 2014 at 05:32:26PM +0100, Marek Polacek wrote:
> This doesn't really fix the PR, but solves a related issue, where we
> have e.g.
> struct U {};
> static struct U b[6];
>
> int foo (struct U *p, struct U *q)
> {
> return q - p;
> }
> int main()
> {
> return foo (&b[0], &b[4]);
On 01/13/2014 05:32 PM, Marek Polacek wrote:
This doesn't really fix the PR, but solves a related issue, where we
have e.g.
struct U {};
static struct U b[6];
int foo (struct U *p, struct U *q)
{
return q - p;
}
int main()
{
return foo (&b[0], &b[4]);
}
Such a program SIGFPEs at runtim
This doesn't really fix the PR, but solves a related issue, where we
have e.g.
struct U {};
static struct U b[6];
int foo (struct U *p, struct U *q)
{
return q - p;
}
int main()
{
return foo (&b[0], &b[4]);
}
Such a program SIGFPEs at runtime. But subtraction of pointers to empty
structures/u
17 matches
Mail list logo