Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 541001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:17:54+00:00 2026-05-13T10:17:54+00:00

As we all know and love .NET does throw an IntegerOverflow exception every time

  • 0

As we all know and love .NET does throw an IntegerOverflow exception every time an integer overflows. I think this is a very good thing.

But I wonder how they make this fast. x86 does not trap on integer overflows and I would be surprised if other architectures would allow one to do that. The best solution I have found for x86 is to put an “INTO” instruction after every single arithmetic operation. But I assume that would result in a noticeable slowdown.

They could do some static checking in the compiler to avoid this in cases when it can be proofed that the operation can not overflow. But what about performance critical inner loops when the compiler can’t determine the outcome of the operations?

I tried to look at the Mono source but I couldn’t find the spot where they do these checks.

So does anyone have a clue what they really do? I really would like to know.

On a side note: Is there a way to see the x86 code the .NET JITC emits?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:17:55+00:00Added an answer on May 13, 2026 at 10:17 am

    It throws only if you are within a checked context, either in the source or as a setting in the project (this is language dependent). The result of which is to out put a different IL instruction.

    This is just a specific example of the general problem of arithmetic overflow and the x86 JIT implementation will doubtless insert a check of the relevant flags after any such operation with an instruction to throw an exception if the flags are set.

    the instructions (using addition as an example) are:

    • add to add two numbers (with wrap around overflow)
    • add.ovf to add two numbers and trap signed overflow
    • add.ovf.un to add two numbers and trap unsigned overflow

    There is indeed a certain level of compiler verification in that constant folding occurs and the resulting value must fit in the assigned variable. Other static analysis measures are possible but there are limits to what can be trapped.

    If you wish to see the emitted JIT code simply debug the relevant code in mixed mode and take a look at the disassembly, stack, registers as you would a normal program. Alternatively go and take a look in the ngen images (this is tricky as the format is susceptible to change).

    Note that doing this via VS, you may wish to start the program as normal (in Release mode), then attach the debugger since the result of the JIT is different depending on whether a debugger is attached and whether the assembly is marked as disallowing optimizations (the default for debug builds)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 278k
  • Answers 278k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try this instead: $(function() { $('#item_category').change(function(){ this.form.submit(); }); }); May 13, 2026 at 3:12 pm
  • Editorial Team
    Editorial Team added an answer In your base class, make the doSomething method virtual: public:… May 13, 2026 at 3:12 pm
  • Editorial Team
    Editorial Team added an answer Since App Engine allows async urlfetch calls but does not… May 13, 2026 at 3:12 pm

Related Questions

I'm curious as to the exact conditions that cause an application to be Just
When designing a lookup table (enum) in SqlServer 2005, if you know the number
I was wondering whether it would be possible to change the sqlConnectionString used for
We all know that refactoring is good and I love it as much as
We all know that having a good note taking tool is important as a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.