| Liste des Groupes | Revenir à cl c |
In article <110ghmv$21vi3$1@dont-email.me>,I think it is important for tools to be helpful, and it's fine to complain if a tool is being directly unhelpful - or ask for improvements when you think it could be better.
David Brown <david.brown@hesbynett.no> wrote:[snip]Eh...I think those people have a point.
As for my '"modern compilers are evil" crowd' comment, there are people
(not anyone involved in this discussion) who really do fall into that
camp. I've seen people who are experienced and respected developers
make all sorts of accusations to compiler developers, claiming they are
only interested in high scores on synthetic benchmarks and directly
insulting their motivations and integrity, blaming them for "breaking"
their code that relied on the effects of some kinds of UB. It is always
frustrating when you have code that works fine with one compiler
version, but using another compiler results in failure due to UB in your
code - especially if writing correct code gives inefficient results with
the first compiler. And it's fine to say you'd be happier if a
particular thing that is UB in C were not UB - but it is unreasonable to
blame compiler developers for implementing the language as it is defined.
Note, I don't think that "modern compilers are evil" (I mean,
wow, that's a strong word) and I certainly do not think it is
appropriate to malign the people who write them personally over
what one does with code.
But I _do_ think it is fair to say that UB is very easy to fallIt can certainly happen, yes. And I fully sympathise on these few occasions when changes to the standard has meant that code that previously had defined behaviour, now has different or undefined behaviour. (However, I think that for some kinds of code, programmers could be better at specifying exactly what standards their code requires, and the standards they use when compiling code.)
into in C, that programs that have worked correctly (insofar as
their intended behavior as written) for years can suddenly fail
because latent UB is treated differently in a point revision of
a compiler, and that that (as you point out) can be incredibly
frustrating for the authors.
Regehr called out a dichotomy with UB: programmers using aI think Regehr has made some good points in his writings, but I do not agree with him on everything.
language hate it; compiler writers love it.
Here's my own vignette: I was chatting with a friend who worksI too want a language with well-defined semantics that can be aggressively optimised. But I do not see UB as a hinder to that. I am happy knowing that I cannot divide by 0, or find the square root of a negative number (in the real domain). I am happy knowing that I cannot add two ints if their sum overflows the range of their type, and that I cannot call a function with a different number or type of parameters than its definition. I have a great deal of difficulty seeing how things could be any different, other than in a managed language with significant overhead from run-time checks - and that goes against the "aggressively optimised" requirement.
on LLVM and clang some time ago. I said, "I don't want UB" and
he replied, "no, you really do." I asked him what he meant and
he responded that I wanted a compiler that is capable of
optimizing my program; "sure, but I still don't want UB." We
went on for a bit, and it became clear that he saw UB as _the_
vehicle for unlocking optimization.
I realized that we were not speaking the same language _at all_.
He and I both wanted a language where we could write programs
that yield efficient object code. He saw UB as essential for
that; but what I want is a language with well-defined semantics
that can be aggressively optimized.
That, I think, is the tension: there was a fundamental breakdownCommunication between the separate parties is always an issue, and it is easy for it to be a one-way street with a language standards committee dictating the rules with little attention to feedback, then compiler vendors following these rules without listening to the users.
in communication between the users of the language, and those
defining and implementing it. My subjective sense is that in
the past few years things are getting somewhat better, but it is
hard to evolve something as critical and widely used as C.
I think that is a good way to handle the situation. In my projects, I do not normally upgrade or change toolchains. While I think the risk of UB is small in my own code, small does not mean non-existent. And for my work, generated code that behaves correctly in terms of C semantics but has different execution times or code size might also be an issue - so changes in toolchains mean a lot of extra testing and qualification. In addition, for some microcontrollers the toolchains have relatively small user bases and consequently higher risks of unknown bugs in the toolchains themselves. Sometimes there are also implementation-specific features that change between versions (though that is less of an issue these days).I am not in any way saying that critics of aspects of C (the language,The kernel I am working on has about 5 million lines of code.
the standards, or compiler implementations) should be dismissed or
despised - merely that the example of loop elimination leading to UB and
unexpected results is regularly used as "evidence" by those that hold
extreme positions about C, despite it being very unrealistic for the
issue to cause problems in real coding practice.
That code has been evolving for 40 years; some of it predates
the ISO standards and even the ANSI standard. It has been
updated for newer compilers, sure, but in some places the
treatment is surface-level: using ISO-style function prototypes
and definition syntax, for example. But deep problems remain in
parts, and contraints on engineering resources couple with
economic and business pressures so that it's not going to get
cleaned up any time soon. I'm sure there is UB in it; in fact,
I know there is. But them's the breaks; and yet, customers are
using it in production. Because of this, upgrading toolchains
is laborious and complex, and takes a lot of time, and new
compilers are (rightly) viewed with suspicion. That is not a
great situation, but I don't think anyone is angry at the
compiler people over it.
And just as it's not acceptable to blame compiler writers forBeing dead does not resolve you of the responsibility - the person that wrote the code with UB is the person who wrote the code with the UB, just like any other bugs. That person wrote the code with the error. It might not be fair to hold it against them - there are a great many possible reasons why it was not their fault (typically management is more at fault than the coders!). And placing blame is rarely a useful exercise - usually it does not matter where the bugs came from, only that they are there and need to be fixed or worked around.
implementating the language as it is defined, it's not really
acceptable to blame programmers either; some of the people who
put the UB there are (literally) dead, and there's just not
enough time in the day to go clean it all up. I wish there was
more compassion for that.
As said earlier, C is what it is. I suspect that it willAgreed.
continue to make incremental improvements, but we're basically
stuck with what we have.
- Dan C.
Les messages affichés proviennent d'usenet.