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

  • SEARCH
  • Home
  • 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 8449615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:45:31+00:00 2026-06-10T10:45:31+00:00

Having to follow code – const int WEEKDAYS = 7; const int *pWeekdays =

  • 0

Having to follow code –

    const int WEEKDAYS = 7;
    const int *pWeekdays = &WEEKDAYS;
    *((int*) pWeekdays) = 9;
    cout << WEEKDAYS << endl;

it give output 7 , that is – the line *((int*) pWeekdays) = 9; had no effect or thrown any errors .

Apparently it’s like to do 7 = 9 so why no errors are being thrown ?

  • 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-06-10T10:45:33+00:00Added an answer on June 10, 2026 at 10:45 am

    Casting away constness and thus accessing a const object mutably is simple undefined behaviour. Your program can do anything it wants, and no diagnostic is required.

    Always remember that while it’s true that a crashing program is buggy, a buggy program doesn’t always crash. (Or as Socrates would have said, “not every cat is a fish”.)


    In C++ you should really never use C-style casts. If you had tried the more appropriate static_cast<int*>(pWeekdays), you would have got the correct diagnostic.

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

Sidebar

Related Questions

I'm having a problem with a code that doesnt follow sequential execution although I'm
I'm having some trouble getting an object to follow a path that is drawn
I'm having trouble getting the follow code to work in Internet Explorer, it doesn't
i'm having a problem with a variable at my jquery, follow the code: var
Having trouble linking the Stomp.framework into an iPhone SDK application. http://code.google.com/p/stompframework/ I follow the
I'm having problems with the follow code: Options FollowSymLinks RewriteEngine on RewriteRule ^thing/([^/]+)/?$ index.php?t=$1
This is follow up post where I'm having a problem where my php code
Here http://source.android.com/source/code-style.html#follow-field-naming-conventions it is stated that : Field Names Non-public, non-static field names start
Coding Follow/Unfollow system in CodeIgniter(PHP) & Twitter-Bootstrap. Am also having routes active for the
Having the follow code - enum FileOpenFlags { flagREAD = 1, flagWRITE = 2,

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.