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. C / C++ / MFC
  4. const_cast

const_cast

Scheduled Pinned Locked Moved C / C++ / MFC
questiondebuggingannouncement
2 Posts 2 Posters 0 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
    Jerome Conus
    wrote on last edited by
    #1

    Hi ! I'm facing many problems (app crashs) when my app is compiled in release mode (problems I don't have in debug mode). I noticed that removing some const_cast improved the situation. This makes me wonder : am I allowed to use const_cast ? How can I spot the situations where const_cast should be avoided ? If const_cast is dangerous, why is it provided ? Thanks for your enlightment ! Jerome

    T 1 Reply Last reply
    0
    • J Jerome Conus

      Hi ! I'm facing many problems (app crashs) when my app is compiled in release mode (problems I don't have in debug mode). I noticed that removing some const_cast improved the situation. This makes me wonder : am I allowed to use const_cast ? How can I spot the situations where const_cast should be avoided ? If const_cast is dangerous, why is it provided ? Thanks for your enlightment ! Jerome

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      hian So Jerome BAck!!!! so any way here you's Answer,As MSDN states that,i have maked sentence bold which might be causing problem in your program pointer to any object type or a pointer to a data member can be explicitly converted to a type that is identical except for the const, volatile, and __unaligned qualifiers. For pointers and references, the result will refer to the original object. For pointers to data members, the result will refer to the same member as the original (uncast) pointer to data member. Depending on the type of the referenced object, a write operation through the resulting pointer, reference, or pointer to data member might produce undefined behavior. ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

      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