News for hackers. Stuff that matters.
Re:Proposal for a Friendly Dialect of C by jhallenworld on Wednesday August 27, 2014 @07:49PM (#8235274)
I have strong feelings that the C standard (and, by extension, C compilers) should directly support non-portable code. It means many behaviors are not "undefined"- instead they are "machine dependent". Thus overflow is not undefined- it is _defined_ to depend on the underlying architecture in a specific way.

C is a more useful language if you can make machine specific code this way.

I'm surprised that some of the pointer math issues come up. Why would the compiler assume that a pointer's value is invalid just because the referenced object is out of scope? That's crazy..

Weird results from uninitialized variables can sometimes be OK. I would kind of accept strange things to happen when an uninitialized bool (which is really an int) is not exactly 1 or 0.

Perhaps a better way to deal with the memcpy issue is this: make memcpy() safe (handles 0 size, allows overlapping regions), but create a fast_memcpy() for speed.

Re:Proposal for a Friendly Dialect of C by dllthomas on Wednesday August 27, 2014 @08:23PM (#8235363)
The standard differentiates between "undefined" and "implementation defined".
Re:Proposal for a Friendly Dialect of C by to3m on Wednesday August 27, 2014 @08:40PM (#8235403)
...with one option for undefined behaviour being for it to behave "in some documented manner characteristic of the platform" (C11 para 3.4.3.2). Which is not the same thing as being implementation defined, of course, but is at least a step above simply deciding your program is invalid and generating bogus code because of it.

So compilers could do this stuff already. I have no idea why they don't. C isn't really the language for people who want platform independence.

Re:Proposal for a Friendly Dialect of C by dllthomas on Wednesday August 27, 2014 @11:35PM (#8235803)
Well sure. They don't because you can get better performance if you are able to eliminate branches that you can prove aren't taken.