[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug: yyleng declared as type size_t
From: |
W. L. Estes |
Subject: |
Re: Bug: yyleng declared as type size_t |
Date: |
Tue, 18 Sep 2001 08:22:37 -0400 |
> Here's another possible bug. yyleng in a non-reentrant scanner is defined in
> the skeleton as type 'size_t' instead of 'int'. I stumbled across it while
> building the "lclint" utility, which declares yyleng in a header file as an
> extern of type 'int'. This bug actually breaks the build, because gcc sees
> "conflicting types" in the two declarations.
>
> Can you think of any reason why 'size_t' would be preferred over 'int' for
> yyleng?
yyleng is a length and hence will never be negative. ints can be
negative. as a special bonus (although this has nothing to do with any
bonus program offered by your local grocery store), you'll get that
extra bit as a possible bit in your non-negative range so lengths can
be twice as big using an unsigned type.
--Will