Re: Documentation of abs(3), div(3) etc.
Roland Illig <[email protected]>
| Newsgroups | gmane.os.netbsd.devel.general |
|---|---|
| Message-ID | <[email protected]> |
Christian Biere wrote: > Hi, > > the manpages for abs(3) and its variants define behavior for the "most negative > integer" whereas the standard explicity states that the behavior is undefined > if the result cannot be represented. > > This is a lie anyway because the code looks like > > return a < 0 ? -a : a; > > whereas it obviously means > > return a < 0 ? -(unsigned)a : a; The C standard may say that the behavior is undefined, but that doesn't prevent an implementation from defining it. Assuming that the developers who wrote the man pages had checked the compiler's documentation as well as the documentation of all the hardware platforms NetBSD supports, and assuming further that all these platforms behave the same, there is nothing wrong with that documentation. Of course, there should be test suites for these functions, making sure that the behavior indeed matches the documentation. Roland > I have attached a patch for the manpages. I've also changed "BUGS" to "CAVEAT" > because these aren't bugs, it's broken by design. You mean, two's complement is broken by design? ;) Roland