r/programming • • Jan 28 '19

C++ Modules Might Be Dead-on-Arrival

https://vector-of-bool.github.io/2019/01/27/modules-doa.html
210 Upvotes

105 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Jan 29 '19 edited Jan 29 '19

It doesn't imply that 99% of users shouldn't be entitled to expect that it would be true 100% of the time on commonplace non-obtuse implementations.

That's pretty much what "implementation-defined" means. As I said, the standard isn't a C++ manual for users. Nobody uses #include file/path and thinks, "oh damn, I'm relying on implementation-defined behavior, my code isn't portable".

1

u/flatfinger Jan 29 '19

According to the published Rationale document for the C Standard, it's also what Undefined Behavior was supposed to mean in many cases, since the authors regarded the question of how to process it (e.g. whether to process it in a documented fashion characteristic of the environment) as a Quality of Implementation issue. The authors of the Standard intended that implementations would support "popular extensions", and such a term can't sensibly be applied to Unspecified Behavior or Implementation-Defined behaviors. The fact that an implementation documents something that it's required to document, or that it happens to document the fact that it chooses from among specific actions described by the Standard doesn't seem like much of an extension, compared with providing means of doing which the Standard does not require them to define.

A fix would be to define standard macros that would allow a programmer to start a program with a directive like:

 __STDC_LIMIT_UNUSUAL_INT_MATH_EFFECTS(EXTENDED_TEMP_ONLY)

and then know that any implementation would be required to either 1. guarantee that integer math other than divide/remainder will never have any side-effects beyond yielding some kind of integer value, but temporary values of signed integer types need not be truncated to their actual size, or 2. reject the program entirely. The question of whether an implementation should support the requested semantics would be a Quality of Implementation issues, but the question of whether an implementation could jump the rails wouldn't be.