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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:41:25+00:00 2026-05-15T20:41:25+00:00

I have a class with the only constructor like this: IntroScreen::IntroScreen(Game *game) : View(game),

  • 0

I have a class with the only constructor like this:

IntroScreen::IntroScreen(Game *game) :
    View(game), counter(0.0f), message(-1), continueAlpha(255),
    continueVisible(false), screenAlpha(255), fadeIn(false), fadeOut(false)
{
}

And somewhere in a method I have this if-statement

if (counter > 10.0f)

And Valgrind says for that line:

Conditional jump or move depends on uninitialised value(s)

But I initialized it in my initializer list! And I think I believe Valgrind. Because, sometimes everything goes correct and sometimes nothing happens…. So, maybe counter gets a wrong value and so it takes long until the counter reaches 10.

I already check my code where I use counter for some errors. But I think you can’t “un-initialize a value” with a C++ statement…

These are ALL the lines (except in the initializer list) where I use counter:

counter += speed;
counter = 20.0f;
counter += game->getSpeedFactor();
if (counter >= 15.f)
counter = 15.f;
if (counter > 10.0f)

Valgrind gives the same output for screenAlpha.

Both variables are private and I have no friend classes….

So, what is going on? What the problem could be?

Edit:

I printed the value out:
In the constructor, it was correnct: 0
In my method, it was rubbish. It prited random values like:

  • -97298.8...
  • -106542.2...

The print statement is the first line of the method where all assignments to counter are in.

Second Edit:

Can this be the problem!!??

In my Game class, I initialize that IntroScreen like this:

Game::Game() : /* Some other stuff .... */  , view(new IntroScreen(this))`
{}

view is here a pointer to an abstract super-type of IntroScreen called View.

  • 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-15T20:41:25+00:00Added an answer on May 15, 2026 at 8:41 pm

    I found it:

    getSpeedFactor() returns only the first time I call it a complete wrong number because of time-functions like gettimeofday(). The start value (to time how long it took to update the game) is set initialized to zero and the stop value is micros of the day: which gives a time of the whole day instead of the update time. Once the game loop ran once, the wrong value is corrected (because of the start value gets assigned). But the first time the game-logic was executed, I used getSpeedFactor() to assign counter, so that way counter get a value of -10000…

    Thanks all.

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

Sidebar

Related Questions

I have a custom class that uses boost mutexes and locks like this (only
I have a class like this: class Cow @feet : 4 constructor: (@name) ->
I can't figure out why I'm getting this error. I only have one class
So say I have a class like this: class A { public: A( SomeHugeClass*
I have classes like this one: class SomeObject { public function __construct($param1, $param2) {
Say I have a class like this: class Person { private $value; public function
I have a Generic class like this : public class Mapper<TEntity, TDataAccess> where TEntity
Let's say I have two classes that look like this: public class ByteFilter {
I may be going about this backwards... I have a class which is like
I have a type like this sealed class Foo[A](val value: A) object Foo {

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.