473,320 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Another level 4 warning compiler bug (C4702)

Just wanted to throw out there a VC7.1 compiler bug when usingwarning level 4. The following code will demonstrate theproblem:
class TestClass
{
public:
// Initialized float member, generates C4702 warning
TestClass() : m_fValue(1.f)
{
try
{
throw 1;
}
catch ( ... ) // C4702 unreachable code warning issuedhere
{
std::cout
<< "Caught exception in default TestClassconstructor"
<< std::endl;
}
}

// Does not initialize float member, does not generatewarning
TestClass( int p_i )
{
try
{
throw p_i;
}
catch ( ... )
{
std::cout
<< "Caught exception in parameterized TestClassconstructor"
<< std::endl;
}
}

protected:

float m_fValue;
};

int _tmain(int argc, _TCHAR* argv[])
{
TestClass test1;
TestClass test2(2);

char cDelay;
std::cin >> cDelay;

return 0;
}

The default TestClass constructor will generate the C4702"unreachable code" warning at the catch when compiled withwarning level 4, but the parameterized constructor will not. Ithas something to do with initializing the float member as if youtake this away, the warning no longer happens. Running the codedemonstrates that the "unreachable code" in the catch isexecuted. Perhaps a VC developer will see this and make sureits fixed in the 2005 version.

--------------------------------
From: J.D. Herron

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>rdjasGxAHE+zaerWSbIw/Q==</Id>
Nov 17 '05 #1
6 2164
>Just wanted to throw out there a VC7.1 compiler bug when using warning level 4.

Strange, I've just pasted your code into a VC7.1 console application
and can't reproduce any warning (at /W4).

Dave
Nov 17 '05 #2
David Lowndes wrote:
Just wanted to throw out there a VC7.1 compiler bug when using warning level 4.

Strange, I've just pasted your code into a VC7.1 console application
and can't reproduce any warning (at /W4).

Dave


Did you do a release build? This diagnostic is only emitted when the
optimizer runs.

Ronald
Nov 17 '05 #3
>>>Just wanted to throw out there a VC7.1 compiler bug when using warning level 4.


Strange, I've just pasted your code into a VC7.1 console application
and can't reproduce any warning (at /W4).

Dave


Did you do a release build? This diagnostic is only emitted when the
optimizer runs.


No, I didn't!

As I've pointed out in the past, having consistency in the compiler
between debug and release builds would be beneficial - if only to
prevent some of my public embarrassments :)

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
Nov 17 '05 #4
>>Did you do a release build? This diagnostic is only emitted when the
optimizer runs.


No, I didn't!


But I have now - still no warning for me.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
Nov 17 '05 #5

"David Lowndes" <da****@example.invalid> skrev i meddelandet
news:g6********************************@4ax.com...
Just wanted to throw out there a VC7.1 compiler bug when using
warning level 4.
Strange, I've just pasted your code into a VC7.1 console application
and can't reproduce any warning (at /W4).

Dave


Did you do a release build? This diagnostic is only emitted when the
optimizer runs.


No, I didn't!

As I've pointed out in the past, having consistency in the compiler
between debug and release builds would be beneficial - if only to
prevent some of my public embarrassments :)


The problem here, of course, is that you have to run a data flow
analysis to detect some of the problems. If you don't run the optimizer,
you will not notice that it would fail.
Bo Persson
Nov 17 '05 #6
>>As I've pointed out in the past, having consistency in the compiler
between debug and release builds would be beneficial - if only to
prevent some of my public embarrassments :)

The problem here, of course, is that you have to run a data flow
analysis to detect some of the problems. If you don't run the optimizer,
you will not notice that it would fail.
Bo Persson


Yes,

Specifically it would increase compile time, sometimes significantly.

Ronald
Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Maciej Pilichowski | last post by:
Hello there, The short version -- how to set warning level just for one specific file, or more exactly how to relax warning level for it? The long version -- I try to work at maximum warning...
3
by: Bryan Parkoff | last post by:
I tell C++ Compiler to use level 4 warning instead of level 3 warning so all variables can be calculated accuracy with no prone error. It will give you a warning like this. unsigned short A =...
43
by: Anitha | last post by:
Hi I observed something while coding the other day: if I declare a character array as char s, and try to use it as any other character array..it works perfectly fine most of the times. It...
11
by: Joe Fallon | last post by:
Public MustInherit Class My3rdLevelClass Inherits GeneratedClass Public Shared Function GetSomething() As String Return "Something" End Function
27
by: Madhav | last post by:
Hi all, I did not understand why do the global vars are initialized to NULL where as the block level variables have random values? I know that the C standard requires this as was mentioned in a...
4
by: tired_of_spaghetti | last post by:
I'm curious as to the need for the new keyword in an inherited method redefinition, so - Suppose I have a class hierachy that looks like public class Base { public virtual void myMethod()...
9
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to...
5
by: B. | last post by:
We just recently move to code from VC++6 to VC++.NET 2005 and upgrade the warning level from 3 to 4. In debug mode, we compile the application with no warning no error, but when I build it in...
43
by: Adem24 | last post by:
The World Joint Programming Language Standardization Committe (WJPLSC) hereby proclaims to the people of the world that a new programming language is needed for the benefit of the whole mankind in...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.