On Mon, Feb 19, 2018 at 9:04 PM, Alain Ketterlin <al...@universite-de-strasbourg.fr.invalid> wrote: > Chris Angelico <ros...@gmail.com> writes: > >> On Mon, Feb 19, 2018 at 7:40 PM, Alain Ketterlin >> <al...@universite-de-strasbourg.fr.invalid> wrote: > >>> No. C has much stronger rules, not on casting, but on accessing the >>> pointees, which basically invalidates your argument. Refer to the C >>> standard for details. >> >> Really? What rules? > > Look at the C11 standard, section 6.3.2.3 ("Pointers"), 6.5.ยง6-7 > ("effective types"), and 6.5.3.2 ("Address and indirection operators"). > It is tiring to constantly correct misunderstandings about pointer > casting and dereferencing. > >> $ cat demo.c; gcc -Wall demo.c; ./a.out > [...] > > If you don't know what undefined behavior is, better avoid C. Your > program has UB, anything can happen, including a seemingly sensible > result.
Sure it can. But I don't know what you can mean by "stronger rules" if all it says is "that's undefined". Saying that behaviour is undefined does NOT mean that C has a stronger type system. I got no errors, not even a warning in -Wall mode, so there is no indication that my code did something wrong. -- https://mail.python.org/mailman/listinfo/python-list