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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:31:11+00:00 2026-05-27T02:31:11+00:00

We have a legacy c++ .dll compiled for windows under visual studio. We have

  • 0

We have a legacy c++ .dll compiled for windows under visual studio. We have been running into issues where we get different results when we compile the program using different compiler options.

I have done a pretty simple port so that I can compile it under linux using g++. I just wanted to see what kind of warnings gcc would throw at me and possibly try to run it using valgrind to look for possible erros.

So that is the background. Here is the question. We have a bunch of fprintf function calls that print to a log file. When compiled under g++, I get warnings like this.

../f11.cpp:754:128: warning: format ‘%i’ expects type ‘int’, but argument 8 has type ‘long unsigned int’

Obviously this is a bad thing we need to fix, but I am just curious about the potential consequences of ignoring this warning? Are the consequences only limited to the output in the log file, or could this cause things like buffer overruns or any other type of situation where we are overwriting memory without knowing it?

  • 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-27T02:31:11+00:00Added an answer on May 27, 2026 at 2:31 am

    You are getting such warnings because of code like

     long x;
     printf ("x=%i\n", x);
    

    On a 64 bits x86-64 Linux machine, what is probably happenning is that printf implementation would call va_arg(arglist, int) for the x argument. Since int is 32 bits and long is 64 bits, the 64 bits value is probably truncated to its 32 lower bits, which in that particular case probably don’t harm much.

    If it is a scanf ("%i", &x); things become much much uglier. Probably, only 32 bits out of 64 of the long x get changed, and that will break the code later.

    But as everyone responded, this is undefined behavior. you’ll feel sorry if you don’t fix it or at the very least, add a big fat /* FIXME */ comment for the person working on the code in a few weeks or months.

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

Sidebar

Related Questions

I have a Visual Studio 2008 project with some legacy native C++ DLL projects,
I have a new PC running Windows 7 and Visual Studio 2010, and need
I have legacy C# code and I am using Visual Studio 2008. I am
We have a legacy vb6 program using Active Reports 2. We have been running
We have a legacy ASP.net powered site running on a IIS server, the site
I have a legacy delphi dll. I created a class library that imports the
I have a legacy 3rd party COM .dll that is used to provide an
Windows 7, C++, VS2008 I have a COM DLL that needs to be registered
I have a legacy VB (visual basic) 6 application that connects to Oracle 8
We have a c++ legacy application and have been extending it with c# applets

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.