[cfe-dev] Nasty problem in sizeof evaluation?

Daniel Dunbar daniel at zuster.org
Wed Sep 29 08:43:35 PDT 2010


Hi Abramo,

I'm not sure if this has been resolved, but in general I think it is
better to just file a bug instead of sending to the list (if it is
obviously a bug).

A number of people do actively watch bugzilla and try to stay on top
of new bugs, and this ensures we don't lose track of it.

 - Daniel

On Sun, Sep 26, 2010 at 12:44 AM, Abramo Bagnara
<abramo.bagnara at gmail.com> wrote:
>
> $ cat p.c
> #define HUGE (1LL<<61)
> typedef char a[HUGE];
> typedef char b[(long long)sizeof(a)-1];
>
> $ clang -m64 p.c
> p.c:3:16: error: array size is negative
> typedef char b[(long long)sizeof(a)-1];
>               ^~~~~~~~~~~~~~~~~~~~~~
> 1 error generated.
>
> I believe this is due to the fact that type size is evaluated in bits
> unit with 64 bits of precision and then it is divided by 8.
>
> This lead to the observed problem.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>




More information about the cfe-dev mailing list