Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. How does the compiler achieve the CRT remapping?

How does the compiler achieve the CRT remapping?

Scheduled Pinned Locked Moved Managed C++/CLI
announcementcsharpc++databasevisual-studio
1 Posts 1 Posters 12 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    John Schroedl
    wrote on last edited by
    #1

    We've noticed that calling C functions such as abs() will call into the C Runtime implementation of abs() for a Debug build but will call into System::Math::Abs in a Release build. This was pretty unexpected as the substitution of System::Math::Abs will trigger .NET exceptions such as System::OverflowException for out of bounds conditions whereas the CRT will always return a value. For example, this will crash in Release but exit normally in Debug. Yes, it's UB so anything is possible but it also calls System::Math::Abs even if the args are normal values. This just illustrates the exception vs non-exception.

    #include
    #include

    int main(int, char**)
    {
    return std::abs(INT_MIN);
    }

    Does anyone have any links or good search terms for this C Runtime substitution behavior they're doing? ex. Does the loader redirect calls into System:: entrypoints for things besides abs()? I'd like to see that list so I know which calls may need to be guarded with try/catch. I can understand that they do this swap for performance purposes and to avoid extra managed->native->managed transitions but it was news to me that this was ocurring. John

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups