[LLVMbugs] [Bug 7854] New: User-definable arithmetic overflow handler

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Aug 9 14:13:04 PDT 2010


           Summary: User-definable arithmetic overflow handler
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: llvmbugs at contacts.eelis.net
                CC: llvmbugs at cs.uiuc.edu

Clang's -ftrapv used to generate calls to __overflow_handler, which the user
could define. I used this functionality in an IRC C++ compilation&execution bot
to give nice verbose diagnostics like "Overflow: 2147483647 + 3" that told
users exactly what was wrong with their snippets.

Unfortunately, this functionality was removed from Clang in revision 110490:


Now all we get is an opaque trap with no information about what went wrong.

It's really a shame to see useful functionality disappear, hence this
enhancement request.

However, I do /not/ request that the previous -ftrapv behavior be restored
verbatim, because:
1. the "return a replacement value" functionality was awkward and I don't need
it anyway;
2. having -ftrapv be compatible with gcc makes sense.

Instead, I would suggest making user-definable handlers for overflow detection
part of -fcatch-undefined-behavior, with the requirement that the handler must
not return. Indeed, the ability to have user-defined handlers would also be
welcome for the other instances of undefined behavior detected by
-fcatch-undefined-behavior, so that those too can print accurate diagnostics
about what went wrong, but that's another story. :-)

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list