MSVC 7.0 compiler bug in debug mode 
Author Message
 MSVC 7.0 compiler bug in debug mode

Hello, All!

Please, look at this sample:

#include <iostream>

int make()
{
   return -1;

Quote:
}

int main()
{
   int a = -1;
   int& c = a;

Quote:
>   const int& b = make();

   int st[200] = { 0 };

   std::cout << b;

   return 0;

Quote:
}

    Well... Function make() returns temporary object and b refer to this
temp object. In the Debug mode next statement (int st[200] = { 0 }) erases
value refered by b (it seems referenced value has wrong stack placement),
but in Release mode everythings is Ok (temporary object placed just after
reference to it in stack).
    I tested and more complicated objects returned by make(). (generally
speaking I meet this bug returning my object) The result is same: statement
"int st[200] = { 0 }" override referenced object memory.

    Well, question is... Does VC7.0 not support references to temp objects
(but in Release it works!!!) or this is a realy compiler bug?

p.s. I use MSVC 7.0.9466 Win2000sp3.

p.p.s. Under MSVC 6.0sp5 Win2000sp3 above code works properly (referenced
value leaves untouched) in both cases. (Debug and Release)




Fri, 27 May 2005 19:39:25 GMT  
 MSVC 7.0 compiler bug in debug mode
Alex,
thank you for this report. It exposes real problem in Visual C++ compiler.
VC++ team will look at this issue.
Reference id for your records is 50877.
Possible work around right now is to move initialization of the array st
above initialization of other local variables.

--
Dmitri Kotchetov
Visual C++ Team
This posting is provided "AS IS" with no warranties, and confers no rights.



Quote:
> Hello, All!

> Please, look at this sample:

> #include <iostream>

> int make()
> {
>    return -1;
> }

> int main()
> {
>    int a = -1;
>    int& c = a;

> >   const int& b = make();

>    int st[200] = { 0 };

>    std::cout << b;

>    return 0;
> }

>     Well... Function make() returns temporary object and b refer to this
> temp object. In the Debug mode next statement (int st[200] = { 0 }) erases
> value refered by b (it seems referenced value has wrong stack placement),
> but in Release mode everythings is Ok (temporary object placed just after
> reference to it in stack).
>     I tested and more complicated objects returned by make(). (generally
> speaking I meet this bug returning my object) The result is same:
statement
> "int st[200] = { 0 }" override referenced object memory.

>     Well, question is... Does VC7.0 not support references to temp objects
> (but in Release it works!!!) or this is a realy compiler bug?

> p.s. I use MSVC 7.0.9466 Win2000sp3.

> p.p.s. Under MSVC 6.0sp5 Win2000sp3 above code works properly (referenced
> value leaves untouched) in both cases. (Debug and Release)





Sat, 28 May 2005 04:03:59 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. MSVC run-time bug in Malloc in Debug Mode

2. MSVC run-time bug in Malloc in Debug Mode

3. Bug in MSVC 7.0 (Output Iterator)

4. MIDL compiler fails during release mode but works fine in debug mode

5. Need Source for MSVC 1.52 real mode compiler

6. Error in Debug mode using MSVC

7. MSVC compiler bug [?] - private constructor called illegaly

8. MSVC compiler bug [?] - private constructor called illegaly

9. MSVC 5.0 BUG: Compiler Seises up on Templates in Nested Namespaces

10. MSVC 5.0 BUG: Compiler Seizes up on Templates in Nested Namespace

11. Finding a bug that doesn't exist in debug mode

12. compiler errors in debug mode

 

 
Powered by phpBB® Forum Software