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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:49:02+00:00 2026-06-09T07:49:02+00:00

I was debugging some C++ code in GDB and I found out that some

  • 0

I was debugging some C++ code in GDB and I found out that some calls were making use of a so-called “synthetic pointer”. Googling around did not produce any meaningful result. Searching here on SO, most questions with “synthetic” in their title refer to some Java feature (even if they suggest me that “synthetic”, in this context, could mean “something generated artificially by the compiler”).

E.g., look at this backtrace, took from one operation, performed in the constructor of MyClass, over one class member called m (this code has been compiled with -O2):

#0  MyClass (arg=..., this=<synthetic pointer>) at somefile.h:144
144     m->lock();
gdb$ print this
$1 = (MyClass * const) <synthetic pointer>
gdb$ print *this
$2 = <optimized out>

The stack trace above clearly states that this is a pointer to an object that has been optimized out, but how is it possible that a method (i.e., its constructor) has been called on it? My wild guess is that, even if the enclosed object (m) is actively used in the code, some optimizations let the compiler decide that the enclosing object (this) is not really necessary. Since the method call m->lock(), that cannot be optimized out, must be emitted somewhere, the compiler creates a “fake” (synthetic?) object, located nowhere in memory, just to wrap m.

I do not have a strong compiler experience, so I do not know if this conclusion really makes sense. Could someone please shed some light on this?

Thank you.

  • 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-09T07:49:04+00:00Added an answer on June 9, 2026 at 7:49 am

    A compiler can determine whether this is actually dereferenced (i.e. using the specific CPU details, not the general C++ rules). If a method doesn’t actually dereference this, there’s no need to have a phyiscal representation available.

    [edit]
    In the comments, jww mentioned another case. A singleton has only one copy, so a smart compiler can treat its members as globals. That means the address of singleton->foo is just the constant &singleton + offset(foo). As a result of this optimization, the singleton methods don’t need to actually dereference this either to get access to the singleton members, so it again can be optimized out.

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

Sidebar

Related Questions

I have been playing around with some debugging and wrote some C code that
Possible Duplicate: Switching to assembly in gdb I am debugging some code in gdb.
I am debugging some code and I want to find out when a particular
I have some debugging code that if executed while running with GBD attached should
I am debugging some C code with gdb. My program has a variable of
I am using g++ 4.1.2 and gdb 7.2 I am debugging code that uses
I was debugging some code in Visual Studio 2005, when I noticed that the
While debugging some code in gdb, I want to see which line will be
I'm debugging some code and need to find out where a DoCmd.TransferSpreadsheet acImport, ,
I am debugging some C# code that uses Ado.net to call a stored proc

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.