Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#9236 closed Bugs (wontfix)

Catch programmer errors with asserts, not exceptions

Reported by: Domagoj Šarić Owned by: John Maddock
Milestone: To Be Determined Component: multiprecision
Version: Boost 1.54.0 Severity: Optimization
Keywords: Cc:

Description

e.g. "powm requires a positive exponent."

Change History (5)

comment:1 by John Maddock, 9 years ago

I believe this to be a true runtime error which should be checked and reported via an exception. Note that if you pass an unsigned integer as the exponent then the check is omitted, and in any case the cost of the check likely to be insignificant compared to the rest of the code.

There are however some inconsistencies in the way these checks are applied, which I'll fix shortly.

comment:2 by John Maddock, 9 years ago

(In [86258]) Optimize copying of allocator-free cpp_int's via memcpy. Fix consistency of checks for exponents < 0 in powm. Fixes #9231. Refs #9236.

comment:3 by John Maddock, 9 years ago

Resolution: wontfix
Status: newclosed

comment:4 by Domagoj Šarić, 9 years ago

  • I wrote all those tickets in a bit of a hurry so I didn't check whether that one source code line I pasted is actually the one I ran into when stepping through your code
  • regardless, aren't exceptions for exceptional cases outside of a programmer's direct influence (network, filesystem, memory allocation,...)? IOW isn't an invalid input to a function a programmer error?
  • apply other comments on EH from #9234...

comment:5 by John Maddock, 9 years ago

It's not a programmer error if the arguments come from user input (for example).

Note: See TracTickets for help on using tickets.