On Tuesday, September 23, 2014 4:00:02 PM UTC-4, Martin Bonner wrote:
> On Saturday, 20 September 2014 07:40:02 UTC+1, Rick C. Hodgin wrote:
> > Also, on conflicting types, such as 5 for int and
> > char, if the bytes they occupy would all map to
> > the same location in the union, the cast would
> > not be required.
>
> That would be a terrible idea! It means that code would
> compile on a little-endian machine, but not a big-endian one.
> (For example)
I think to remove it from allowance would place an excessive and
unnecessary burden on every little-endian developer, demanding
that they cast everything explicitly when it's not needed for
their architecture. Not every developer writes cross-architecture
code.
And there are and should be some penalties big-endian developers pay
for their choices. The burden should be on THOSE developers, and not
on ALL developers because of shortcomings in their architecture. :-)
> I agree that C99 designated initializers would be a much
> better solution:
> - They have already been cast into standardese.
> - If gcc doesn't support them for C++, it's probably not hard to
> make it do so (so we can gain implementation experience).
> - They would be of more general utility than just initializing
> unions.
I agree that designated initializers should be available. I think
that would be a great feature.
I also think that requiring designated initializers places an excessive
and unnecessary burden on EVERY developer when the underlying fundamental
initializer is unambiguous and could be populated correctly by value
alone, or could be correctly mapped as on little-endian architectures,
or even on some big-endian combinations also mapped (char to int, for
example, could be mapped merely by being offset by 3 bytes in the data).
Best regards,
Rick C. Hodgin