Re: [PATCH] evaluate: reject post-ops on void*

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry for the late reply.

On Sun, Jan 22, 2012 at 3:31 PM, Jan Pokorný <pokorny_jan@xxxxxxxxx> wrote:
> Following example haven't been linearized correctly:
>
>        static void *inc_ptr(void *a) {
>                return ++a;
>        }
>
> test-linearize:
>
>        <entry-point>
>        add.32      %r2 <- %arg1, $-1
>        ret.32      %r2

Yes, you discover a bug in the area we did not treat
type size consistently.

> --- a/evaluate.c
> +++ b/evaluate.c
> @@ -1711,7 +1711,8 @@ static struct symbol *evaluate_postop(struct expression *expr)
>                multiply = 1;
>        } else if (class == TYPE_PTR) {
>                struct symbol *target = examine_pointer_target(ctype);
> -               if (!is_function(target))
> +               /* beside function, reject also void* (due to sizeof(void)) */
> +               if (target != &void_ctype && !is_function(target))
>                        multiply = bits_to_bytes(target->bit_size);
>        }

Good catch, but it does not cover all the special case yet.
If you look at evaluate_sizeof(), there are 3 different types need special
handling: void, bool, function.

Same thing should be apply to implicit sizeof operations. They should
share some code rather than enumerate the special case in two different
places. Let me think about it more.

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux