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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:02:13+00:00 2026-06-05T04:02:13+00:00

I have recently fixed a bug in an application of mine: the problem was

  • 0

I have recently fixed a bug in an application of mine: the problem was that an object that resides on the stack had a field left uninitialized.

The object had a class declaration of this type:

struct A{
    int somefield, someotherfield;
    A(): someotherfield(0) {}
}

and when declaring a local variable (like A var; in a function), somefield was left uninitialized, and so a read of it would return a randomish value.

I was certain that fields of a class, which don’t appear in the constructor initialization list, would always get initialized by a synthesized trivial constructor (in the case of an int, a zero value). Evidently I am wrong.

So what are the general rules about implicit field initialization?

  • 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-05T04:02:14+00:00Added an answer on June 5, 2026 at 4:02 am
    • classes and structs are initialized by contructor
    • Basic types int double char short … are not initialized and contain random numbers
    • Pointers are not initialized and point to random positions
    • arrays of classes or structs cause each element to be initialized by its constructor
    • arrays of basic types or pointers are random.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have had a bug recently that only manifested itself when the library was
We have recently started using git and had a nasty problem when someone committed
I recently encountered a problem with my site. I have a position:fixed div which
I have recently upgraded my ASP.NET MVC application from beta to version 1. And
I have recently stumbled upon a problem with selecting relationship details from a 1
I have recently become interested in the field(s) of data mining and machine learning.
I have recently started to learn Objective-C and write my tests using OCUnit that
This one is a long story: i have recently built a win32 application in
I'm currently working on a game/engine that uses OpenGL for rendering, and recently have
Recently I discovered a problem on the midas and I fixed it, the problem

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.