From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marc Espie To: egcs@egcs.cygnus.com Subject: Re: type based aliasing again Date: Thu, 09 Sep 1999 07:12:00 -0000 Message-id: <199909091415.QAA30861@quatramaran.ens.fr> References: <199909090211.TAA03202@kankakee.wrs.com> X-SW-Source: 1999-09/msg00354.html In article < 199909090211.TAA03202@kankakee.wrs.com > you write: >Is it less confusing to a user to have the compiler predictably >generate wrong code, or for it to almost always generate right code, >even for bad code, except in really obscure and hard to understand >cases? As far as aliasing goes, what would do wonders would be to have a thorough section of the documentation explaining what goes on, in understandable english, not standards legalese. A few examples of code that works, and code that WILL break would help immensely as well... Specifically, issues with `poor man inheritance in C', where one casts structure pointers about to more generic classes, and other instances of concrete code (the kind of which you find in kernels) would be useful. ... and I won't volunteer for that one, as I am still confused about what kind of casts are valid and which kinds are not. For instance, I've been reviewing some m4 source, which uses a stack declared like this: union type { char *string; int position; } stack[MAX_SIZE]; and then proceeds to cast stack to (char **) and pass this as argv to a macro processing function. Is this code actually valid under ANSI aliasing rules ? (I know that it needs sizeof(char *) == sizeof(union type), but that's another point) From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marc Espie To: egcs@egcs.cygnus.com Subject: Re: type based aliasing again Date: Thu, 30 Sep 1999 18:02:00 -0000 Message-ID: <199909091415.QAA30861@quatramaran.ens.fr> References: <199909090211.TAA03202@kankakee.wrs.com> X-SW-Source: 1999-09n/msg00354.html Message-ID: <19990930180200.5KevM0UPoRPxHJB6yozI9MmhVZDD5TP626uKOv-wz9c@z> In article < 199909090211.TAA03202@kankakee.wrs.com > you write: >Is it less confusing to a user to have the compiler predictably >generate wrong code, or for it to almost always generate right code, >even for bad code, except in really obscure and hard to understand >cases? As far as aliasing goes, what would do wonders would be to have a thorough section of the documentation explaining what goes on, in understandable english, not standards legalese. A few examples of code that works, and code that WILL break would help immensely as well... Specifically, issues with `poor man inheritance in C', where one casts structure pointers about to more generic classes, and other instances of concrete code (the kind of which you find in kernels) would be useful. ... and I won't volunteer for that one, as I am still confused about what kind of casts are valid and which kinds are not. For instance, I've been reviewing some m4 source, which uses a stack declared like this: union type { char *string; int position; } stack[MAX_SIZE]; and then proceeds to cast stack to (char **) and pass this as argv to a macro processing function. Is this code actually valid under ANSI aliasing rules ? (I know that it needs sizeof(char *) == sizeof(union type), but that's another point)