News for hackers. Stuff that matters.
Re:C – Preliminary C2x Charter by naasking on Thursday March 17, 2016 @01:46PM (#11306129)
> Does anyone have some better ideas?

gcc's C extensions have some good ideas [1], particularly:

1. typeof(e) operator: great for use in macros

2. labels as values: used in just about every language interpeter

3. statement expressions: great for use in macros

4. fixed point types: who wants to hack their own fixed precision arithmetic?

5. vector extensions

6. arithmetic functions with overflow checking

I think all of the above would make good additions to the C standard.

[1] https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html

Re:C – Preliminary C2x Charter by kayamon on Thursday March 17, 2016 @02:15PM (#11306344)
Well said.

I'd like to see the gcc ".." operator for range-based switch cases and designated initializers become standardized.

Re:C – Preliminary C2x Charter by kps on Thursday March 17, 2016 @05:56PM (#11307958)
TR 18037¹ defines fixed point arithmetic, but it does not seem well supported.

¹ http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1169.pdf

Re:C – Preliminary C2x Charter by _kst_ on Thursday March 17, 2016 @06:43PM (#11308234)
As far as I can tell, a programmer can't specify the number of fractional bits. The type "unsigned short _Fract", for example, has a number of fraction bits determined by the implementation within limits imposed by the standard. There's no way to ask for a type with, for example, 12 integral bits and 4 fractional bits.

Do hardware constraints make, for example, an 8.8 bit format easier to handle than a 12.4 format?

Compare Ada's fixed-point types, which let you specify the range and delta:

    type Fixed is delta 0.0625 range 0.0 .. 4095.9375;
Re:C – Preliminary C2x Charter by brandmeyer on Thursday March 17, 2016 @06:52PM (#11308294)
> Do hardware constraints make, for example, an 8.8 bit format easier to handle than a 12.4 format?

Sometimes they do. For example, the ARMv7 DSP extensions support signed Q0.31 and signed Q0.15 arithmetic much faster than any other fixed-point format.

Re:C – Preliminary C2x Charter by tropo on Thursday March 17, 2016 @05:51PM (#11307910)
I'm not liking the fixed-point types.

I'd rather see the ability to place an attribute on a floating-point variable that would inform the compiler that fixed-point might be suitable. You'd specify the requirements that need to be met, and the compiler would choose the fastest format for the current architecture. That format could be fixed-point, decimal float, IEEE float, or something weirder.

For example, your requirements could include: minimum magnitude, maximum magnitude, minimum value, maximum value, maximum additive error, maximum multiplicative error, signed zero needed or not, NaN signed/unsupported/unsigned, infinity distinct from NaN and/or the largest number, etc.

You say what you need for correctness, and the compiler makes it happen.

Re:C – Preliminary C2x Charter by _kst_ on Thursday March 17, 2016 @06:44PM (#11308240)
Fixed-point and floating-point types have very different behavior. I can't think of a case where I'd want to let the compiler decide which one to use.
Re:C – Preliminary C2x Charter by tropo on Thursday March 17, 2016 @09:06PM (#11309083)
No, normally what people desire of a fixed-point representation is a subset of a floating-point representation. Most fixed-point stuff is prototyped as floating-point, then painfully converted into a mess of nasty macros. Ideally there would be assertions to protect against failure due to the limited functionality of the fixed-point type, but probably you don't bother.

It's not maintainable.

We should be able to take that prototype, mark it up with hints for the compiler, and then build with fixed-point enabled.

Re:C – Preliminary C2x Charter by PeCaN on Thursday March 17, 2016 @02:24PM (#11306412)
As long as we keep __builtin_apply out of the standard, GCC is loaded with good ideas.
Re:C – Preliminary C2x Charter by naasking on Thursday March 17, 2016 @03:35PM (#11306952)
Yeah, after reading that I was really wondering about the use case for those extensions at the time they were added. I honestly can't think of any now.