News for hackers. Stuff that matters.
Re:C++ proposal: There are 8 bits in a byte by Quekid5 on Thursday October 17, 2024 @07:17PM (#41874788)
JF Bastien is a legend for this, haha.

I would be amazed if there's any even remotely relevant code that deals meaningfully with CHAR_BIT != 8 these days.

(... and yes, it's about time.)

Re:C++ proposal: There are 8 bits in a byte by Animats on Thursday October 17, 2024 @07:54PM (#41875024)
Here's a bit of 40 year old code I wrote which originally ran on 36-bit PDP-10 machines, but will work on non-36 bit machines.[1] It's a self-contained piece of code to check passwords for being obvious. This will detect any word in the UNIX dictionary, and most English words, using something that's vaguely like a Bloom filter.

This is so old it predates ANSI C; it's in K&R C. It used to show up on various academic sites. Now it's obsolete enough to have scrolled off Google. I've seen copies of this on various academic sites over the years, but it seems to have finally scrolled off.

I think we can dispense with non 8-bit bytes at this point.

[1] https://animats.com/source/obvious/obvious.c

Re:C++ proposal: There are 8 bits in a byte by kstrauser on Thursday October 17, 2024 @11:09PM (#41876044)
Huh, that’s clever!
Re:C++ proposal: There are 8 bits in a byte by shawn_w on Thursday October 17, 2024 @07:28PM (#41874845)
DSP chips are a common exception that people bring up. I think some TI made ones have 64 bit chars.

Edit: I see TFA mentions them but questions how relevant C++ is in that sort of embedded environment.

Re:C++ proposal: There are 8 bits in a byte by Quekid5 on Thursday October 17, 2024 @07:34PM (#41874898)
Yes, but you're already in specialized territory if you're using that
Re:C++ proposal: There are 8 bits in a byte by nullc on Thursday October 17, 2024 @07:28PM (#41874846)
The tms320c28x DSPs have 16 bit char, so e.g. the Opus audio codec codebase works with 16-bit char (or at least it did at one point -- I wouldn't be shocked if it broke from time to time, since I don't think anyone runs regression tests on such a platform).

For some DSP-ish sort of processors I think it doesn't make sense to have addressability at char level, and the gates to support it would be better spent on better 16 and 32 bit multipliers. ::shrugs::

I feel kind of ambivalent about the standards proposal. We already have fixed size types. If you want/need an exact type, that already exists. The non-fixed size types set minimums and allow platforms to set larger sizes for performance reasons.

Having no fast 8-bit level access is a perfectly reasonable decision for a small DSP.

Might it be better instead to migrate many users of char to (u)int8_t?

The proposed alternative of CHAR_BIT congruent to 0 mod 8 also sounds pretty reasonable, in that it captures the existing non-8-bit char platforms and also the justification for non-8-bit char platforms (that if you're not doing much string processing but instead doing all math processing, the additional hardware for efficient 8 bit access is a total waste).

Re:C++ proposal: There are 8 bits in a byte by dathinab on Thursday October 17, 2024 @07:38PM (#41874932)
I thinks it's fine to relegate non 8 bit chars to non-standard C given that a lot of software anyway assumes 8bit bytes already implicitly. Non standard extensions for certain use-cases isn't anything new for C compilers. Also it's a C++ proposal I'm not sure if you program DSPs with C++ :think:
Re:C++ proposal: There are 8 bits in a byte by jfbastien on Thursday October 17, 2024 @10:38PM (#41875911)
I added a mention of TI's hardware in my latest draft: https://isocpp.org/files/papers/D3477R1.html
Re:C++ proposal: There are 8 bits in a byte by nullc on Friday October 18, 2024 @05:17PM (#41883578)
Any thoughts on the fact that some vendors basically don't offer a C compiler now? E.g. MSVC has essentially forced C++ limitations back onto the C language to reduce C++ vs C maintance costs?