Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: type-checking for metafiedness? (was: Re: Cores almost on demand in patcompile())
On Sat, 15 Oct 2016 18:14:44 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> Wouldn't it suffice to use
> typedef char *unmeta_t;
> typedef unsigned char *meta_t;
>
> (or the reverse if we believe we're mostly going to be working on
> meta_t). If we do that and also enable the GCC warnings -Wtype-limits
> -Wconversion -Wformat-signedness would we not get adequate verbosity
> without changing pointer arithmetic and dereferencing?
-Wformat-signedness didn't exist when I tried (old version, 4.5.1), but
adding -Wtype-limits and -Wconversion produced 2348 type conversion
errors and 63 implicit conversion of negative integer errors.
But we don't need new warnings --- compilers, including gcc, are much
more finnicky about converting pointer types than the base types, and
assigning individual characters from strings around isn't part of our
problems (except where we alrady have the STOUC() hack).
The only possible subtlety is on some systems char is already unsigned.
However, it seems gcc considers all three of "unsigned char *", "signed
char *", and "char *" as distinct pointer types and making meta_t either
of the first two throws up errors like:
ptr.c:11:9: warning: comparison of distinct pointer types lacks a cast
So this looks workable. Obviously this means continuing to keep
unmetafied lengths separate.
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author