On Monday, November 20, 2017 at 1:11:29 PM UTC-5,
supe...@casperkitty.com wrote:
> On Saturday, November 18, 2017 at 7:26:21 AM UTC-6, Rick C. Hodgin wrote:
> > On Friday, November 17, 2017 at 4:53:30 PM UTC-5,
supe...@casperkitty.com wrote:
> > > Ideally the Standard would define common things like a way of specifying
> > > commonplace address semantics rather than having many different compiler
> > > vendors each define such a directive (thus making it necessary to have
> > > implementations that seek maximum compatibility support many different
> > > ways of saying the same thing) but even that would be better than not
> > > having any compiler-independent way of specifying what is supposed to be
> > > meant by an integer-to-pointer conversion.
> >
> > Wouldn't the argument here be that in C today someone can essentially
> > do that with the inclusion of certain headers, and subsequent tests
> > for those features existing in regular C code?
>
> Having code specify what it needs, and having a compiler balk at a
> specification it can't meet, is better than having code test whether
> an implementation can meet its need, in at least two major ways:
>
> 1. Quality implementations may be able to adjust their configuration
> automatically in response to directives that indicate requirements.
That's possible, but the features you'd be enabling wouldn't otherwise
exist in a compilation without the enabling factor. So the only direct
contact they'd have would be the fringe connection on the interface
between the two portions, and that could be handled reasonably well-
enough for all but exceedingly performance critical implementations
with the linker and the external .lib/.obj file I'd think.
> 2. It would be practical to have an UB sanitizer silently ignore things
> like integer overflow within code that is marked with directives that
> would specify the behavior thereof behavior, while squawking at
> overflows that occur in code not thus marked. It would, by contrast,
> be much harder to make a sanitizer behave reliably with code that
> relies upon feature tests and #error directives. If enabling an
> overflow sanitizer would cause a compiler to report that it doesn't
> guarantee anything about overflow behavior, code that relies upon
> wrapping behavior wouldn't be able to run without the sanitizer
> disabled. If the sanitizer is disabled, it would have no way to
> detect modules which accidentally omitted the "refuse to compile on
> implementations that don't guarantee overflow behavior" logic.
Wouldn't it be desirable to have those UB sanitizers report on their
full range of findings, and then run them through a post-parser that
identifies, based on knowledge of the locations for code blocks in the
live/running ABI, that they are known? I would think all such cases
would want to be reported on, and then flagged as being known, rather
than be flagged as being known and then not reported on.d
> I would like to see the Standard defined in such a way that existing
> compilers that support the required behaviors could be made compatible
> with code that requires them, merely by writing a compiler-specific
> header file that would then satisfy the requirements of the Standard
> with most such code, and would be usable with the vast majority (though
> in some cases it might be necessary to predefine a macro that would
> bypass the safety checks; such bypassing would violate a requirement
> that implementations reject code whose demands they cannot meet, but
> would allow programs to be used on implementations which are known to
> meet requirements in all cases that matter).
I have a similar view, but I look at it as introducing add-ons to the
actual compiler, those which then are able to parse new syntax or new
directives that weren't part of the baseline compiler.
In this way, everything becomes part of the compiler, and there isn't
really an enabler, unless you want to implement it that way, but
rather when you launch the compiler you specify which language(s) you
want to support with their features added to the compile-time compiler
database, so that when you specify certain languages, or ceratin
extensions of languages, then those feature are just automatically
enabled.
In my view, you would be shifting the burden of compilation from
source code to compiler-line directives, though it could also be done
in source code, but I honestly think that's the back-door way to do
it. The source code should be written for the target, and there
should be an external framework of some kind (a project with project
settings, for example), which then has information about how to do
the compile, how to link, how to import, how to export, etc.
--
Rick C. Hodgin