possible bug in VC6, VC7, VC7.1 
Author Message
 possible bug in VC6, VC7, VC7.1

Hi

The compiler failes to catch the following

In the header file if we declare a variable like this

static int i = 0;

and include this header in many other implementation files compiler and
liker will work happily.Compiler will not warn about this. Though it is
syntaxly correct but can be a major cause of bugs.

With kindest regards

Shrishail Rana



Thu, 08 Dec 2005 20:00:55 GMT  
 possible bug in VC6, VC7, VC7.1
Just don't put data definitions in the header file.
By design rules, the header files contain only declaration and may contain
template function definitions.

There are many bad design habits that may cause bugs, but the compiler can't
provide any enforcement against them. Maybe LINT has some rules to check for
such problems.


Quote:
> Hi

> The compiler failes to catch the following

> In the header file if we declare a variable like this

> static int i = 0;

> and include this header in many other implementation files compiler and
> liker will work happily.Compiler will not warn about this. Though it is
> syntaxly correct but can be a major cause of bugs.

> With kindest regards

> Shrishail Rana



Thu, 08 Dec 2005 21:46:42 GMT  
 possible bug in VC6, VC7, VC7.1

Quote:
> Hi

> The compiler failes to catch the following

> In the header file if we declare a variable like this

> static int i = 0;

> and include this header in many other implementation files compiler
> and liker will work happily.Compiler will not warn about this. Though
> it is syntaxly correct but can be a major cause of bugs.

> With kindest regards

> Shrishail Rana

I don't know why you think it is a possible bug. You get a different
variable (each with internal linkage) in each file that includes the header.
If that is not what you want, then don't do it.

--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)



Thu, 08 Dec 2005 22:31:21 GMT  
 possible bug in VC6, VC7, VC7.1

Quote:



>> Hi

>> The compiler failes to catch the following

>> In the header file if we declare a variable like this

>> static int i = 0;

>> and include this header in many other implementation files compiler
>> and liker will work happily.Compiler will not warn about this. Though
>> it is syntaxly correct but can be a major cause of bugs.

>> With kindest regards

>> Shrishail Rana

>I don't know why you think it is a possible bug. You get a different
>variable (each with internal linkage) in each file that includes the header.
>If that is not what you want, then don't do it.

To add to that, people sometimes think "header" files are something special.
They're not. When the preprocessor sees a #include, it simply replaces it
with the contents of whatever is #included. The compiler proper never sees
"header" files or even "source" files. All it sees is the result of
preprocessing, the "translation unit".

--
Doug Harrison
Microsoft MVP - Visual C++



Fri, 09 Dec 2005 04:30:06 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Possible bug in vc7.0 (and vc7.1)

2. Possible Bug in VC++.Net VC7 Debugger?

3. Invalid Program Format(Possible VC7++ BUG??)

4. VC6/VC7 bug with ?: operator and throw expressions.

5. __int64 negative value initialization bug in VC6 (SP5), may be VC7 also

6. my bug or VC7 bug ?

7. Does this VC6 compiler bug exist in VC7 (and can someone confirm the bug in VC6)?

8. Does this VC6 compiler bug exist in VC7 (and can someone confirm the bug in VC6)?

9. Does this VC6 compiler bug exist in VC7 (and can someone confirm the bug in VC6)?

10. .Net VC7 project opened in VC6 can't find MSVCP70D.dll

11. Converting DevStudio Add-in from VC6 to VC7

12. COleDateTime semantics change from VC6 to VC7

 

 
Powered by phpBB® Forum Software