Subject: Re: bogus CC warning?
To: None <>
From: Aidan Cully <>
List: tech-toolchain
Date: 04/11/1999 02:38:35
Content-Type: text/plain; charset=us-ascii

(I know this belongs on tech-toolchain, but I'm not subscribed their, so
please Cc: me in all replies..  Thanks.)

On Sun, Apr 04, 1999 at 04:55:51PM -0400, Aidan Cully wrote:
> Thanks to a message from Jonathan Stone, I was able to figure out how
> to reproduce this problem in exportable code..  Here's a .c file which
> will (on my box) reproduce the results I'm seeing.  The output I get
> when compiling is:
> albatross:~/src/warn-test% cc -o test -Wall -Werror test.c 
> cc1: warnings being treated as errors
> test.c: In function `main':
> test.c:13: warning: passing arg 1 of `proto' from incompatible pointer type
> test.c: In function `proto':
> test.c:22: warning: comparison of distinct pointer types lacks a cast
> test.c:24: warning: passing arg 1 of `proto' from incompatible pointer type
> The source for the program:
> #include <string.h>
> #include <stdio.h>
> typedef unsigned char array[256];
> void proto(const array *string, array *string2);
> int main(int argc, char *argv[])
> {
>     array str1, str2;
>     strcpy((char*) str1, "Hello, world!");
>     strcpy((char*) str2, "Hello, new world!");
>     proto(&str1, &str2);
>     return(0);
> }
> void proto(string, string2)
>     const array *string;
>     array *string2;
> {
>     printf("string: %s\n", (char*) string);
>     if (string == string2)
>         return;
>     proto(string2, string2);
> }
> Does anyone else get these results?

I was able to build a patch that fixed this, if it is, indeed, a bug..
(I don't have any C-references, and I don't feel like looking through
one even if I did.)  Can someone in the know please confirm with me
that this behaviour _is_ a bug, and not defined C behaviour?  And that
the attached patch (which I installed on my system to get kerberos
building again) is correct?  In particular, I'm not sure that in all
the instances that comptypes gets called that type1 is always the lhs
and type2 is always the rhs..


Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="typeck.patch"

--- gnu/dist/gcc/c-typeck.c.orig	Sun Apr 11 02:25:29 1999
+++ gnu/dist/gcc/c-typeck.c	Sun Apr 11 02:26:21 1999
@@ -447,7 +447,8 @@
   /* Qualifiers must match.  */
-  if (TYPE_READONLY (t1) != TYPE_READONLY (t2))
+  /* readonly only matters in the lhs if the rhs is readonly. */
+  if (TYPE_READONLY (t2) == 1 && TYPE_READONLY (t1) == 0)
     return 0;
   if (TYPE_VOLATILE (t1) != TYPE_VOLATILE (t2))
     return 0;