Message ID | 20181029153952.13927-6-ben.dooks@codethink.co.uk (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | [1/5] tokenize: check show_string() for NULL pointer | expand |
On Mon, Oct 29, 2018 at 03:39:52PM +0000, Ben Dooks wrote: > If both t1 and t2 are ptr_ctype_noderef then it should be ok to ignore > the address-space of both (in the case of passing to printf style > functions). > > Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> > --- > evaluate.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/evaluate.c b/evaluate.c > index 2a98a9b..0d5b8ad 100644 > --- a/evaluate.c > +++ b/evaluate.c > @@ -718,7 +718,8 @@ const char *type_difference(struct ctype *c1, struct ctype *c2, > /* XXX: we ought to compare sizes */ > break; > case SYM_PTR: > - if (as1 != as2) > + if (as1 != as2 && (t1 != &ptr_ctype_noderef && > + t2 != &ptr_ctype_noderef)) > return "different address spaces"; This can't work like you wish because no argument will ever be set to ptr_ctype_noderef. And even if you try to it can only work for a noderef void pointer because, for example, a noderef pointer to an int has a type which can be described like: pointer(int) + noderef while ptr_ctype_noderef is like: pointer(void) + noderef Or, equivalently, the base type of 'pointer to X' is 'int' and not 'generic pointer type'. In other words, there is no links and there can't be a link between a 'noderef pointer to type X' and 'noderef pointer to void' unless X is 'void'. Kind regards, -- Luc
diff --git a/evaluate.c b/evaluate.c index 2a98a9b..0d5b8ad 100644 --- a/evaluate.c +++ b/evaluate.c @@ -718,7 +718,8 @@ const char *type_difference(struct ctype *c1, struct ctype *c2, /* XXX: we ought to compare sizes */ break; case SYM_PTR: - if (as1 != as2) + if (as1 != as2 && (t1 != &ptr_ctype_noderef && + t2 != &ptr_ctype_noderef)) return "different address spaces"; /* MOD_SPECIFIER is due to idiocy in parse.c */ if ((mod1 ^ mod2) & ~MOD_IGNORE & ~MOD_SPECIFIER)
If both t1 and t2 are ptr_ctype_noderef then it should be ok to ignore the address-space of both (in the case of passing to printf style functions). Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> --- evaluate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)