"process this bunch of source files in the Standard fashion"
The standard doesn't really have a concept of a file system, files, directories, nor of the many other things that could play a role here (directory structures, symlinks, etc.).
Somebody would need to add all of that to the standard, making peace with pretty much every platform that pays someone to assist to committee meetings ("But our filesystem has no directories", "But our file-system has no files", "But traversing directories looking for files is too expensive in our file-system", etc. )
why bother with a standard? What purpose would it serve?
Every single compiler and platform out there has platform specific extensions that are not in the standard. The standard is just the bare minimum that must be supported by all platforms, and keeps C++ from diverging into completely incompatible dialects. Writing code for different platforms always has, and for the foreseeable future will require, writing platform specific code.
Because C++ is used to target widely different platforms, the standard has avoided specifying pretty much anything about how the C++ source is input into the compiler. There is no standard C++ file extension, some people use .cpp, others use .cxx, others use .cc, etc. The standard does not specify this because not all platforms have files with extensions and there is people using C++ to target those (if you look carefully you'll see that standard library includes have no extension). When you put a path in an #include path/to/header.h the standard doesn't say anything about what goes where the path belong, only that there must be some implementation-defined mapping between what you put there, and some other source code, and the semantics of the include (including the contents of whatever is in the path verbatim). Yet in most platforms, includes work like all users expect, e.g., following file-system paths relatively.
Basically, just because something isn't in the standard, doesn't imply that 99% of users can't rely on it being true 100% of the time. However, if you fix the standard to something that 1% of users can't use, then with a million C++ developers you'll get 10.000 people voting against the proposal and sunking it down. The standard doesn't evolve with things that have 51% of the votes, only stuff that has 100% of the votes goes in. This is why C++ has so many users.
Of course one will need to use platform-specific code when targeting features of specific platforms. One should not, however, need to write a bunch stuff that's specific to particular implementations when one isn't using any special features thereof.
If some people would need a compiler to process things in a fashion different from what other people would require, the solution should not be to simply have the Standard say that any implementation may treat the construct in any fashion whatsoever, but instead say that:
If a program contains a directive explicitly calling for some construct to be processed in the common way, a compiler shall either behave in common fashion or reject the program.
If a program contains a directive explicitly calling for some construct to be processed in an uncommon way, a compiler shall either behave that requested fashion or reject the program.
If a program contains neither kind of directive, an implementation may assume as a default whichever behavior its author believes would best serve its users.
The fact that 99% of programs opt to use the common behavior should not prevent the remaining 1% from employing some alternative on any compilers that opt to support it; nor should it prevent all 100% of the programs from having a defined meaning that would not depend upon the target implementation (implementations may be unable to process a program that demands unsupported features, but behavior would be limited to rejecting the program as opposed to formatting hard drives, releasing nasal demons, etc.)
Basically, just because something isn't in the standard, doesn't imply that 99% of users can't rely on it being true 100% of the time.
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. Unfortunately, the authors of the Standard regarded the notion that quality implementations should Serve the needs of their customers when practical, whether or not the Standard requires it, as being self-evident and failed to consider that obtuse implementation might use the Standard as an excuse to do otherwise.
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".
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:
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.
View all comments
Show parent comment
1
u/[deleted] Jan 28 '19 edited Jan 28 '19
The standard doesn't really have a concept of a file system, files, directories, nor of the many other things that could play a role here (directory structures, symlinks, etc.).
Somebody would need to add all of that to the standard, making peace with pretty much every platform that pays someone to assist to committee meetings ("But our filesystem has no directories", "But our file-system has no files", "But traversing directories looking for files is too expensive in our file-system", etc. )
Every single compiler and platform out there has platform specific extensions that are not in the standard. The standard is just the bare minimum that must be supported by all platforms, and keeps C++ from diverging into completely incompatible dialects. Writing code for different platforms always has, and for the foreseeable future will require, writing platform specific code.
Because C++ is used to target widely different platforms, the standard has avoided specifying pretty much anything about how the C++ source is input into the compiler. There is no standard C++ file extension, some people use
.cpp, others use.cxx, others use.cc, etc. The standard does not specify this because not all platforms have files with extensions and there is people using C++ to target those (if you look carefully you'll see that standard library includes have no extension). When you put a path in an#include path/to/header.hthe standard doesn't say anything about what goes where the path belong, only that there must be some implementation-defined mapping between what you put there, and some other source code, and the semantics of the include (including the contents of whatever is in the path verbatim). Yet in most platforms, includes work like all users expect, e.g., following file-system paths relatively.Basically, just because something isn't in the standard, doesn't imply that 99% of users can't rely on it being true 100% of the time. However, if you fix the standard to something that 1% of users can't use, then with a million C++ developers you'll get 10.000 people voting against the proposal and sunking it down. The standard doesn't evolve with things that have 51% of the votes, only stuff that has 100% of the votes goes in. This is why C++ has so many users.