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 6944205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:15:21+00:00 2026-05-27T13:15:21+00:00

(4.1/1) If the object to which the lvalue refers is not an object of

  • 0

(4.1/1) If the object to which the lvalue refers is not an object of
type T and is not an object of a type derived from T
, or if the object
is uninitialized, a program that necessitates this conversion has
undefined behavior.

From this, I assume

struct B {
     int x; };

B *p;
*p; //undefined behavior

*p is a lvalue which refers to an uninitialized object. How can it refer to an object which is not the type of ‘B’ or its derived type? Am i misunderstanding something?

  • 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-27T13:15:22+00:00Added an answer on May 27, 2026 at 1:15 pm

    Easy:

    int n = 5;
    double * p = reinterpret_cast<double*>(&n);
    
    *p += 1.0; // undefined behaviour: p points to an int, not a double
    
    ++*reinterpret_cast<int*>(p);  // legal; pointer can be cast back-and-forth
    

    Less easy:

    union bogus { int * a; double * b; } B;
    int n;
    B.a = &n;
    *B.b += 1.0; // undefined behaviour
    

    Common C pitfall (produces no diagnostic!):

    void do_a(void * p) { ++*reinterpret_cast<int*>(p); }
    void do_b(void * p) { *reinterpret_cast<double*>(p) += 1.0; }
    
    int main() { int n = 4; do_b(&n); /* eek */ }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JPA object which has a many-to-many relationship like this: @Entity public
When I serialize an object which has a DateTime in it this is returning
I have an object which has several properties that are set when the object
I have this JSON Object which I receive from the api.moviedb.com It is pretty
I have an object which has inner objects and properties defined like this: var
I have a productVariant object which has child product object. I want to show
I have this object which is an instance of a superclass. I want to
I have an XElement object which has a number of attributes and I simply
I have this json object (which i don't really know what is inside) and
I have an object which has a state property, for example state = 'state4'

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.