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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:50:56+00:00 2026-06-10T03:50:56+00:00

I have the following code, but in this line of code I have warning

  • 0

I have the following code, but in this line of code I have warning x[i] = (rhs[i] - x[i - 1]) / b;, compiler is telling me that rhs[i] is a garbage value. Why it’s happend? And how to remove this warning?

double* getFirstControlPoints(double* rhs, const int n) {
    double *x;
    x = (double*)malloc(n * sizeof(double));
    double *tmp; // Temp workspace.
    tmp = (double*)malloc(n * sizeof(double));

    double b = 2.0;
    x[0] = rhs[0] / b;
    for (int i = 1; i < n; i++) // Decomposition and forward substitution.
    {
        tmp[i] = 1 / b;
        b = (i < n - 1 ? 4.0 : 3.5) - tmp[i];
        x[i] = (rhs[i] - x[i - 1]) / b; //The left operand of '-' is a garbage value
    }
    for (int i = 1; i < n; i++) {
        x[n - i - 1] -= tmp[n - i] * x[n - i]; // Backsubstitution.
    }
    free(tmp);
    return x;
}

enter image description here

enter image description here

All compiler warnings and calling getFirstControlPoints you may see on screenshots.

  • 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-10T03:50:58+00:00Added an answer on June 10, 2026 at 3:50 am

    You need a check to make sure you have at least 4 points in the points array because this loop (line 333):

    for (NSInteger i = 1 ; i < n - 1 ; ++i) {
        // initialisation stuff
    }
    

    will not execute at all for n = 0, 1, 2.

    Assume that points has 3 objects in it, At line 311 you set n to the count – 1 i.e. n == 2

    Then the loop condition is i < 2 - 1 i.e. i < 1.

    I think you need the loop condition to be i < n

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

Sidebar

Related Questions

I have the following code (in this case for two images - but in
I have the following code to do this, but how can I do it
I have absolutely no idea why this is happening but the following code seems
This may be a stupid question but I have a code with the following
I have the following line in my program that causes a run-time warning: if
I have the following code: $this->Permissions->updateAll( array('Permissions.user' => $newuser), array('Permissions.user' => $originaluser) ); But
I have the following code that calls the function uint32_pack. This program compiles with
I have the following code in my iPhone application, warning memory leak! This is
I have the following line of code this.htmlSpecialChars = this.getSpecialCharMap(); where private HashMap<String,String> htmlSpecialChars;
I have the following code but it doesnt seem to work: <td align=center style=padding-bottom:52.5px>

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.