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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:07:39+00:00 2026-06-11T01:07:39+00:00

My code contains snippets like these: std::va_list ap; va_start(ap, msgfmt); snprintf_buf buf; const tchar

  • 0

My code contains snippets like these:

    std::va_list ap;
    va_start(ap, msgfmt);
    snprintf_buf buf;
    const tchar * msg = buf.print_va_list(msgfmt, ap);
    va_end(ap);

These are short and va_start() and va_end() are close together so they are not much of a problem. Exceptions from calls in between the two could be a problem (or not?).

Simple test shows that calling va_start() from a function without ellipsis is not allowed. Is calling va_end() from a different function than va_start() was called from allowed or not?

Basically, I am curious if it is possible to use the SBRM/RAII idiom for these calls, even if it were necessary to call va_start() manually and then to pass instance of std::va_list into my RAII/SBRM guard instance?

  • 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-11T01:07:40+00:00Added an answer on June 11, 2026 at 1:07 am

    Unfortunately, no. The specification of va_start and va_end requires that:

    Each invocation of the va_start and va_copy macros
    shall be matched by a corresponding invocation of the va_end macro in the same
    function
    .

    Therefore, va_end must be in the variadic function itself, not a class destructor.

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

Sidebar

Related Questions

I came across some legacy code that contains a function like this: LPCTSTR returnString()
I have a mysql database that contains snippets of latex code, identified by a
I recently discoverd some evil code in some of my clients websites. These snippets
I am converting VBA code that contains the LIKE operator, as in dim sToken
My code contains a table that I need to have a fixed width. The
The following Microsoft example code contains the following: <Grid> ... <Border Name=Content ... >
I have a block of HTML code that contains a button <button class=someButton onclick=openPage('test')></button>
I'm trying to compile some code which contains the following declaration, because I would
I have a black box of code that contains many threads. There is no
I've inherited some python code that contains a rather cryptic decorator. This decorator sets

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.