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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:20:19+00:00 2026-05-13T10:20:19+00:00

I am using a C++ library that provides an object that, for the sake

  • 0

I am using a C++ library that provides an object that, for the sake of simplicity, is more or less like this:

class ExampleSO {
    public double* narray;
};

I have an instance of ExampleSO whose narray is about 200. Some other method ExampleSO::method() does a lot of arithmetic functions with this array and assigns it to different array elements:

ExampleSO::method() {
     // a lot of operations
     narray[50] = narray[1] * narray[2] / narray[40];
     // and so on

This code is generated by another program and it uses a bunch of defines to handle the array elements, so the code looks like this:

#define A narray[0]
#define X narray[1]
#define Y narray[2]
// ...
#define Z narray[40]
// ....
#define U narray[50]
// ... more, until narray[199]
ExampleSO::method() {
     // a lot of operations
     U = X * Y / Z;
     // and so on
}

My problem is that eventually some array elements are NaN and I am trying to debug the code to see why. I have already found out some of them, which are mainly caused by divisions by zero, others by exponentiation by very small numbers (small as in between 0 and +/-0.1).

With my little knowledge of gdb magic, I managed to see the array elements by display *(this->narray) @ 200, but this array is very big and therefore, unreadable.

So debugging this piece of code has turned out to be a bundersome task, because the #defines hide me the position of the element, the array is way too big and because so many elements become NaN that I get lost.

My question is: what ideas/suggestions do you have to help me debug this code? Perhaps a conditional breakpoint when the first array element becomes NaN would be useful? How could I do that with such structure?

Thanks!

  • 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-13T10:20:20+00:00Added an answer on May 13, 2026 at 10:20 am
    1. Rewrite it. The structure you describe is horrible beyond description.
    2. Write a python script to turn the #defines into gdb variable aliases, so that you can refer to them symbolically.
    3. Use array syntax in gdb: p narray[12]
    4. Add some debugging helper functions and call them from the debugger: p printMyFavoriteValues(narray)
    5. Learn how to enable signalling NaNs. It is different on Windows versus Mac versus Linux.

    #ifdef DARWIN
        _mm_setcsr( _MM_MASK_MASK &~
                  (_MM_MASK_OVERFLOW|_MM_MASK_INVALID|_MM_MASK_DIV_ZERO) );
    #else
        feenableexcept(FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID);
    #endif
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 295k
  • Answers 295k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This isn't really a Perl-specific problem, but a matter of… May 13, 2026 at 6:55 pm
  • Editorial Team
    Editorial Team added an answer I have worked on many commercial high volume systems using… May 13, 2026 at 6:55 pm
  • Editorial Team
    Editorial Team added an answer You will have to use explicit cursor positioning for this… May 13, 2026 at 6:55 pm

Related Questions

We have a C++ library that we provide to several different clients. Recently we
I would like to store a mapping of an integer key to a float
The Boost C++ library has Function Template tee The class templates tee_filter and tee_device
I am creating a WPF application that will integrate with an existing system using
I want to get started using Boost. I'm programming a C++ program in Visual

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.