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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:44:37+00:00 2026-06-11T22:44:37+00:00

I have the following struct: struct FeatureMatch { int id1, id2; double score; };

  • 0

I have the following struct:

struct FeatureMatch {
    int id1, id2;
    double score; 
};

which runs fine when called by this function:

void ssdMatchFeatures(const FeatureSet &f1, const FeatureSet &f2, vector<FeatureMatch> &matches, double &totalScore) {
    int m = f1.size();
    int n = f2.size();
    matches.resize(15000);
    totalScore = 0;

    double d;
    double dBest;
    int idBest;
   printf("2");
    for (int i=0; i<m; i++) {
        dBest = 1e100;
        idBest = 0;

        for (int j=0; j<n; j++) {
            d = distanceSSD(f1[i].data, f2[j].data);

            if (d < dBest) {
        dBest = d;
        idBest = f2[j].id;
            }
        }
        printf("1\n");
        matches[i].id1 = f1[i].id;
        matches[i].id2 = idBest;
        matches[i].score = -dBest;
     //   matches[i].second=1;
        totalScore += matches[i].score;
    }

    printf("3");
}

However, as soon as I modify the struct by adding a new element:

struct FeatureMatch {
    int id1, id2;
    double score, second; 
};

An additional double value called second makes the above function crash on segmentation error. The output of 1,2,3 shows something like:

21
1
1
1
1
.
.
.
1

But never gets to 3 before it crashes.

what is going on here? Even if I never modify matches[i].second, this happens.

  • 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-11T22:44:38+00:00Added an answer on June 11, 2026 at 10:44 pm

    If you change a structure definition, you should rebuild all affected source files if your build tool doesn’t automatically do so. Otherwise, you may link together modules that use different definitions for the structure, which will result in confusing bugs (as you have seen).

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

Sidebar

Related Questions

I have the following struct: struct Node { double linkCost[8]; int val; Node *prevNode;
I have the following struct private struct sData{ public int volume; public System.Timers.Timer aliveTimer;
I have declared the following struct: typedef struct _RECOGNITIONRESULT { int begin_time_ms, end_time_ms; char*
Suppose I have the following simple struct: struct Vector3 { double x; double y;
Say I have the following code: struct date { int day; int month; int
I have the following struct john { int oldA; int A; } myJohn; DWORD
Suppose I have the following struct and function returning a pointer: typedef struct {
I have the following code struct Node { int accnumber; float balance; Node *next;
I have the following types: struct X { int x; X( int val )
I have the following struct: struct Records { int Number; char Name[20]; float Salary;

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.