473,757 Members | 10,263 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 TestClassconstr uctor"
<< 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 TestClassconstr uctor"
<< 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"unreachab le 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 codedemonstrate s that the "unreachabl e 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 2187
>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.c om...
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
2688
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 level /including -Werror/ but lately I have to work with QT and this library generates a lot of warnings. I have read on http://www.artima.com/cppsource/ C++ Coding Standards and tried to do something similar -- i.e. write a wrapper for all QT...
3
1989
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 = 0x8002; unsigned short B = 0x7FFF; unsigned short C = 0; C = A + B; // Warning loss high byte conversion -- 0x8002 + 0x7FFF = 0x10002
43
2737
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 holds strings of any length. I guess what is happening here is that this array initially holds only '\0' and hence is of length 1. But sometimes, when I tried to write some functions and do some
11
1162
by: Joe Fallon | last post by:
Public MustInherit Class My3rdLevelClass Inherits GeneratedClass Public Shared Function GetSomething() As String Return "Something" End Function
27
2814
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 recent thread. I want to know why this descrimination is in place. Can't all the variables be initialised to NULL automatically by the compiler? This would make programming a little easier.
4
1207
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
3136
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 be inserted into a standard web address in the table (the filed name is link) in ddw1 Example address ---
5
3221
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 release mode, there are quite few C4701 warnings and some C2679 errors. Note that some of warning and error happens in debug mode as well and was fixed. Anyone know why some of warning and error happens only in release mode?
43
3688
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 the 21st millenium. This new language not only differs from existing ones by new features and paradigms but which also brings real advantage by rigourously preventing bad programmer habits by omitting features which are outdated. In the proposed...
0
9298
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10072
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9906
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9737
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7286
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.