From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Martin v. Loewis" To: jbuck@synopsys.COM Cc: gcc@gcc.gnu.org Subject: Re: type based aliasing again Date: Thu, 09 Sep 1999 01:38:00 -0000 Message-id: <199909090814.KAA01066@mira.isdn.cs.tu-berlin.de> References: <199909090430.VAA24607@atrus.synopsys.com> X-SW-Source: 1999-09/msg00345.html > Careful. Are you sure that ANSI says that we can't call this an error? > Is the language describing the type rules for accesses distinct from > other language like > > const int foo = 3; > if (0) { > foo = 4; > } > > ? It's illegal to assign to a const, but here we are not assigning to > a const, because the code is unreachable. There's a difference between ill-formed code (which typically must be diagnosed), and code exhibiting undefined behaviour. Your example is of the former category; the aliasing stuff is of the latter. Of course, the compiler may produce warnings which are not diagnostics; it must still accept a well-formed program afterwards. Regards, Martin From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Martin v. Loewis" To: jbuck@synopsys.COM Cc: gcc@gcc.gnu.org Subject: Re: type based aliasing again Date: Thu, 30 Sep 1999 18:02:00 -0000 Message-ID: <199909090814.KAA01066@mira.isdn.cs.tu-berlin.de> References: <199909090430.VAA24607@atrus.synopsys.com> X-SW-Source: 1999-09n/msg00345.html Message-ID: <19990930180200.hXPNr7O1asWTHXMR0hsqy93l6dn-VOcBhvnHDjXboww@z> > Careful. Are you sure that ANSI says that we can't call this an error? > Is the language describing the type rules for accesses distinct from > other language like > > const int foo = 3; > if (0) { > foo = 4; > } > > ? It's illegal to assign to a const, but here we are not assigning to > a const, because the code is unreachable. There's a difference between ill-formed code (which typically must be diagnosed), and code exhibiting undefined behaviour. Your example is of the former category; the aliasing stuff is of the latter. Of course, the compiler may produce warnings which are not diagnostics; it must still accept a well-formed program afterwards. Regards, Martin