Re: [9fans] Undefined Behaviour in C

2015-11-23 Thread Charles Forsyth
There is quite a bit there to work through, but I was struck by one of the responses to a gcc bug report: "you're leading to undefined behaviour - do you understand this simple fact? in such cases compiler can do *anything* with your code." I've seen similar comments before (about

Re: [9fans] Undefined Behaviour in C

2015-11-23 Thread Vasudev Kamath
Ramakrishnan Muthukrishnan writes: > Had been reading the SOSP paper: > > > and this blog post that proposes a simpler C: > I started reading the paper and its interesting. I didn't

[9fans] Undefined Behaviour in C

2015-11-23 Thread Ramakrishnan Muthukrishnan
Had been reading the SOSP paper: and this blog post that proposes a simpler C: I wonder how Plan 9 C compiler, which is a non-ANSI compliant compiler, treats those parts that the ANSI C standard treats as

Re: [9fans] Undefined Behaviour in C

2015-11-23 Thread Charles Forsyth
On 23 November 2015 at 11:32, Charles Forsyth wrote: > The Plan 9 C compiler is firmly in that historical tradition In short: http://www.terzarima.net/images/careful-now.jpg

Re: [9fans] Undefined Behaviour in C

2015-11-23 Thread Brantley Coile
This is an interesting issue to me because I'm becoming more and more aware of a fundamental misunderstanding of C which will make it difficult for people to write efficient code in the future. These two documents show a lack of understanding regarding the reason for undefined behavior and a

Re: [9fans] Undefined Behaviour in C

2015-11-23 Thread Charles Forsyth
On 23 November 2015 at 11:50, Brantley Coile wrote: > These bloated compilers can never be idiot proof because idiots are so > ingenious. One thing that struck me about that earlier gcc example, where the test for "tun" is eliminated because of bad compiler reasoning, is

Re: [9fans] Undefined Behaviour in C

2015-11-23 Thread Brantley Coile
I've lived with the old definition so long that I didn't notice Plan 9's definition, which is not a problem on today's architectures because there are two equally efficient instructions to choose from. Sent from my iPad > On Nov 23, 2015, at 7:05 AM, Charles Forsyth

Re: [9fans] Undefined Behaviour in C

2015-11-23 Thread Charles Forsyth
On 23 November 2015 at 12:17, Brantley Coile wrote: > I've lived with the old definition so long that I didn't notice Plan 9's > definition, which is not a problem on today's architectures because there > are two equally efficient instructions to choose from. There are a

Re: [9fans] Undefined Behaviour in C

2015-11-23 Thread Charles Forsyth
On 23 November 2015 at 10:20, Ramakrishnan Muthukrishnan wrote: > Had been reading the SOSP paper: > > As an example of how tricky it can be, one of their examples is const uint8_t *data = /* buffer head */; const uint8_t