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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:42:23+00:00 2026-05-19T03:42:23+00:00

Ok, folks. I’ve never encountered this before and it boggles the mind and is

  • 0

Ok, folks. I’ve never encountered this before and it boggles the mind and is illogical. I have a somewhat complex loop and I want to try and see if everything is working by putting some printf statements. I look the intermediate products using printf and verify that the answer is ok. Then, when I comment out the printf to the intermediate products, the answer is WRONG. Has anyone ever encountered this? This is driving me insane and I don’t see how the printfs could change an answer…. X_x If it helps, I am using a c/c++ compiler for a DSP. Thanks for any advice..

Here is a snippet…

printf("splitBackground = %d, numWindowPoints = %d\n", splitBackground, numWindowPoints);
splitBackground = splitBackground/numWindowPoints;
printf("%d ", splitBackground);

This is good but when I comment out the first line of code, it turns out to be hugely incorrect. 🙁

  • 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-19T03:42:23+00:00Added an answer on May 19, 2026 at 3:42 am

    Most likely you’ve made a mistake in your code that results in undefined behavior. And “undefined” implies “it might work under some circumstances”.

    Why would inserting a printf make it work? Some possibilities:

    It changes the timing relationships between different parts of your program, or between your program and the rest of the world.

    The printf call inhibits a compiler optimization that might otherwise take place.

    The printf call changes the internal state of the standard library in a way that prevents the bug from occurring.

    The printf call interacts with the hardware in a way that prevents the bug from occurring.

    (Note that many of the same considerations are also true when running under a debugger — thus the term “heisenbug”: a bug that only occurs when you’re not watching for it.)

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

Sidebar

Related Questions

Folks, I just have a quick question about updating my app after it is
Folks, I'm building a pretty standard workflow that I want exposed via a WCF
Do folks have any guidance on when a simple .NET property that fires INotifyPropertyChanged.PropertyChanged
Folks, I have an ASP.NET project which is pretty n-tier, by namespace, but I
Folks, I have method that returns true if all characters are legal and false
Folks, I need a solution that allows drag-and-drop cell over the table. The cells
Folks, we all know that IP blacklisting doesn't work - spammers can come in
Folks, I'm working on a little piece of rich client software that I'd like
Folks, I connect to a large number of SQL Server 2005 databases through SQL
Folks, TIBCO has announced support for WCF channels back in April - has anything

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.