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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:33:07+00:00 2026-06-18T15:33:07+00:00

Using VS2012, I noticed that a switch that’s been working for several years now

  • 0

Using VS2012, I noticed that a switch that’s been working for several years now seems to be broken in Release builds but works correctly (or at least as it used to) in Debug builds. I can’t see anything at all wrong with the code so would appreciate some feedback on the correctness of using return statements from within a switch block.

The following code compiles ok but gives the wrong output in a Release build on Win7 32-bit…

#include <stdio.h>
#include <tchar.h>

class CSomeClass
{
public:
    float GetFloat(int nInt)
    {
        printf("GetFloat() - entered\n");
        switch (nInt)
        {
        case 1 :
            printf("GetFloat() - case 1 entered\n");
            return 0.5F;
        case 0 :
            printf("GetFloat() - case 0 entered\n");
            return 1.0F;
        case 2 :
            printf("GetFloat() - case 2 entered\n");
            return 2.0F;
        case 3 :
            printf("GetFloat() - case 3 entered\n");
            return 3.0F;
        case 4 :
            printf("GetFloat() - case 4 entered\n");
            return 4.0F;
        }
        printf("GetFloat() - exit\n");
        return 1.0F;
    }
};

int _tmain(int argc, _TCHAR* argv[])
{
    CSomeClass pClass;
    float fValue = pClass.GetFloat(3);
    printf("fValue = %f\n", fValue);

    return 0;
}

If you can repeat the problem, and have a MS Connect login, maybe you can vote it up here too?

Actual results

Release build gives the following incorrect result:

GetFloat() - entered
GetFloat() - case 3 entered
fValue = 0.000000

Expected results

Debug build gives the following correct result:

GetFloat() - entered
GetFloat() - case 3 entered
fValue = 3.000000

MS Connect bug report

  • 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-18T15:33:08+00:00Added an answer on June 18, 2026 at 3:33 pm

    It sounds like it might be this bug? Where there is a problem in returning floating point values generated in a similar way?

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

Sidebar

Related Questions

My colleagues and I are using VS2012 for some weeks now. Sometimes after working
I am using VS2010, working on a WinForms application that uses the ReportViewer control
I'm using VS2010. The projects that I'm working on use different source control providers,
I'm using vs2012 and have created a Silverlight 5 out of browser application that
I have been working in a .NET Framework 4 project using server tags like
We just upgraded our code to .Net 4.5 and are using VS2012 now, but
In VS2012 RC, I noticed that the test list editor, tests view and test
I have been developing in WPF using VS2010 for a few months now and
I've got an issue involving a website that I have been using VS 2008
I have a website solution that used to be managed using VS2008. Now since

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.