On Mon, Jan 16, 2017 at 07:33:31PM +0100, Nikos Mavrogiannopoulos wrote:
> On Mon, 2017-01-16 at 02:24 +0100, Thomas Klausner wrote:
> > Hi!
> >
> > Compilation of libtasn1 on NetBSD fails with the default setting of
> > -Werror because of:
> >
> > ASN1.y: In function '_asn1_yylex':
> > ASN1.y:578:9: error: array subscript has type 'char' [-Werror=char-
> > subscripts]
> > if (!isdigit (string[k]))
> > ^
> >
> > NetBSD is pickier with ctype macros than most other operating
> > systems.
>
> Hi,
> I do not see the issue. 'k' is defined as integer. If it is an issue
> with the netbsd compiler please provide a patch to address it.
The problem is not with k, but with the argument of "isdigit", which
is "string[k]". That's defined as char, not unsigned char.
The standard solution is to cast it to (unsigned char), see attached
patch, since it was already checked that it can't be -1 when we get
here.
Cheers,
Thomas
$NetBSD$
--- lib/ASN1.y.orig 2016-04-04 16:53:28.000000000 +0000
+++ lib/ASN1.y
@@ -575,7 +575,7 @@ _asn1_yylex ()
/* Is STRING a number? */
for (k = 0; k < counter; k++)
- if (!isdigit (string[k]))
+ if (!isdigit ((unsigned char)string[k]))
break;
if (k >= counter)
{