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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:56:58+00:00 2026-06-03T05:56:58+00:00

Problem Partically solved: please read bottom The variadic function in question, stripped down to

  • 0

Problem Partically solved: please read bottom

The variadic function in question, stripped down to the bare simplest is:

inline Variant::Variant(int type, int dims, ...)
{
   va_list ap;
   va_start (ap, dims);

   //Removed Variant handling code here

   int i=0;
   for(;i<dims;i++){
      int size = va_arg (ap, int);
   }


   //Likewise, Removed Variant handling code here

   va_end (ap);
}

As you can see, the function in question is an overloaded constructor for my Variant class. This particular constructor takes in the size and number of dimensions when declaring an array.

So this line runs in my main():

Variant(ARRAY_ARRAYTYPE, 3, 800, 22, 22);

and when I breakpoint right after the

int size = va_arg (ap, int);

line in the function, I get the following results:

size holds the value of 800 (correct)
size holds the value of -43587879... (WTF)
size holds the value of 4387643543 (WTF)

Then the program segfaults because obviously those are completely invalid values.

Any ideas? Thanks in advance.

Problem Partically solved: restart somehow fixed that problem but now a new one …

My OTHER variadic function, which is called afterwards, seems to pickup whatever parameters
were passed to the Variant() constructor rather than its own ones. Any ideas?

Variant* ArAcc(Variant* in_variable, ...)
{
  va_list app;
int index=0;

int i, j;
int mult;

  va_start (app, in_variable->arrayaccess->num_dimensions);
  for(i=0;i<in_variable->arrayaccess->num_dimensions;i++){
    mult = 1;
    for(j=i+1;j<in_variable->arrayaccess->num_dimensions;j++){
        mult = mult * in_variable->arrayaccess->dim_sizes[j];

    }
    int size = va_arg (app, int);
    mult = mult * size;
    index += mult;
  }
  va_end (app);

return &((*in_variable)[index]);
}

with…

ArAcc(&SomeVariant, 7, 9);

Thanks in advance.

  • 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-03T05:57:00+00:00Added an answer on June 3, 2026 at 5:57 am

    Edit: I didn’t see that this was already mentioned in a comment.

    If a restart solved the problem, that would indicate to me that the problem isn’t really solved, just happens not to cause symptoms.

    If the first problem really is solved, the following line in the second function may be causing the second problem:

    va_start (app, in_variable->arrayaccess->num_dimensions);
    

    That should be

    va_start (app, in_variable);
    

    of course.

    Based on your comment I suspect that when the first case wasn’t working, you were actually passing a local variable as the second parameter to va_start instead of the function argument.

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

Sidebar

Related Questions

I had a problem that was partially solved. To explain it quickly : I
Problem Why would compiling a program which has an int main(void) main function differ
Solved this ages ago, but this question recently got some attention so I'm adding
Solved This is now solved: In the tmbLoaded function all I had to do
Problem description is here : http://www.spoj.pl/problems/FASHION/ Process : Took two lists as input ,
Problem: I'm making a web service that allows developers to 'register' their Mongoose schemas
Problem statement - [Business] 1---* [Branch] A business must have one or more branch(es).
Problem: returns array, but not in json. Result: must return array with in array.
Problem: I have an address field from an Access database which has been converted
Problem: I have two spreadsheets that each serve different purposes but contain one particular

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.