Funny bug in BC 3.1 
Author Message
 Funny bug in BC 3.1

Hello,

I have found a bug in the Borland C++ 3.1 compiler.
Try to compile the following code (yes, it contains
a syntax error):

int fun(int type)
{

  double x=0;
  int i;

  switch (type) {
    case 1:
                do
                {
                  x+=1;
                } while x<10;

                while (x<20)
                {
                  x+=1;
                }

                i = 0;
                break;
  }

  return i;

Quote:
}

main() {
   return 0;

Quote:
}

/* PF */


Wed, 26 Jun 2002 03:00:00 GMT  
 Funny bug in BC 3.1

Quote:

>/*
>** Alright, I fixed your syntax error.
>** Now tell us, what is the funny bug.
>** You never said what it was.

Because I supposed you to check it yourself :-)
The compiler (Borland C++ 3.1) hangs when trying to compile
the (original) code treated as C++ code. Only compiling, not running.

|  int i;          +-------------- Compiling --------------+
|                  |                                       |
|  switch (type) { | Main file: T.CPP                      |
|    case 1:       | Compiling: EDITOR   T.CPP             |
|                do|                                       |
|                { |                    Total    File      |
|                  |    Lines compiled: 13       13        |
|                } |          Warnings: 0        0         |
|                  |            Errors: 1        1         |
|                wh|                                       |
----------------------------------------------------------------------------
|                  |           Ctrl-Break to quit          |
        UNHANDLED EXCEPTION 0D at 0A47:01CD Error code: 0000
|
 AX = 000D   BX = 0000   CX = 003B   DX = 0ED7
 SI = B47E   DI = 0000   BP = 0FCE   SP = 0FC6
 CS = 0A47   Limit =2057 segment #AF of
C:\LAN\BC\BIN\BC.EXE________________ -
 DS = 05AF   Limit =FFFF segment #4D of C:\LAN\BC\BIN\BC.EXE9 Make  F10 Menu
 ES = 0000   Invalid segment
 SS = 05AF   Limit =FFFF segment #4D of C:\LAN\BC\BIN\BC.EXE
 - 0A47:01C5   C7 46 FC 00 00 C4 5E 0C  26 8B 47 0C 26 0B 47 0E

 You may hit [T] to terminate, but you should reboot as soon as possible,
 as the system is unstable ...

Quote:
>** Since you only add integers to x,
>** why is it a double?

It was a long program which always failed to compile (hanging the
compiler). Finally, I removed most of the code and left only
these few lines causing strange behavior of BC++ 3.1.

Regards
Piotr



Wed, 26 Jun 2002 03:00:00 GMT  
 Funny bug in BC 3.1

Quote:
>Hello,

>I have found a bug in the Borland C++ 3.1 compiler.

No, I have found (at last) a bug in your code...

Quote:
>Try to compile the following code (yes, it contains
>a syntax error):

Yes, there is a syntax error, but BC 3.1 has seen it.

Quote:
>int fun(int type)
>{

>  double x=0;
>  int i;

>  switch (type) {
>    case 1:
>                do
>                {
>                  x+=1;
>                } while x<10;

>                while (x<20)
>                {
>                  x+=1;
>                }

>                i = 0;
>                break;
>  }

>  return i;
>}

>main() {
>   return 0;
>}

Compiling MAIN.C:
Error MAIN.C 22: Do-while statement missing (

After adding the missing () The program does what it has to do (that is
returning 0 when type is 1, and returning an undefined value on other cases
(a Bad Thing).

AFAIK, no other bug about BC 3.1 (one of the best compiler for MS-DOS I
know)
--
-hs-
CLC-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
ISO-C Library: http://www.dinkum.com/htm_cl
"It's specified. But anyone who writes code like that should be
transmogrified into earthworms and fed to ducks." -- Chris Dollin CLC



Wed, 26 Jun 2002 03:00:00 GMT  
 Funny bug in BC 3.1

Quote:

>>I have found a bug in the Borland C++ 3.1 compiler.

>No, I have found (at last) a bug in your code...

I wrote that there WAS an error in this code.
But the compiler ALSO has a bug. Try to save the code
to a file with .cpp extenstion (e.g. test.cpp) and
try to compile it using Borland C++ 3.1 (for DOS).
I have tried it on many systems (installations of BC,
DOS, Windows etc.) and the BC _always_ crashed during
compilation. Only compilation, not runnig. And _crashed_
the whole system, not just reported an error.

And once again: the code should be compiled as C++ source,
not C. With Borland C++ 3.1 for DOS, nothing else.

Quote:
>After adding the missing () The program does what it has to do (that is
>returning 0 when type is 1, and returning an undefined value on other cases
>(a Bad Thing).

I know, it was only an extraction of another, long source code
which always failed to compile _crashing_ the whole system.

Quote:

>AFAIK, no other bug about BC 3.1 (one of the best compiler for MS-DOS I
>know)
>--

Yes, it is a very good compiler, especially the IDE. I like it too.
And I was very surprised when I found this bug :-)
Do you really have a version that does not crash? Here is the code
again (save it as test.cpp):

/**************** TEST.CPP *****************/
int fun(int type)
{
  double x=0;
  int i;
  switch (type) {
    case 1:  do
                {
                  x+=1;
                } while x<10;

                while (x<20)
                {
                  x+=1;
                }

                i = 0;
                break;
  }
  return i;

Quote:
}

main() {
   return 0;
Quote:
}



Wed, 26 Jun 2002 03:00:00 GMT  
 Funny bug in BC 3.1


Quote:


> >/*
> >** Alright, I fixed your syntax error.
> >** Now tell us, what is the funny bug.
> >** You never said what it was.

> Because I supposed you to check it yourself :-)

In comp.lang.c, it's usually best not to assume that people necessarily
have the same compiler as you.

Quote:
> The compiler (Borland C++ 3.1) hangs when trying to compile
> the (original) code treated as C++ code. Only compiling, not running.

This belongs in a Borland newsgroup IMHO.

--
Richard Heathfield

"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.



Wed, 26 Jun 2002 03:00:00 GMT  
 Funny bug in BC 3.1

Quote:
>Because I supposed you to check it yourself :-)

I did, but (obvioulsy) I have not seen any problem when executing the
compiling.

Quote:
>The compiler (Borland C++ 3.1) hangs when trying to compile
>the (original) code treated as C++ code. Only compiling, not running.

>|  int i;          +-------------- Compiling --------------+
>|                  |                                       |
>|  switch (type) { | Main file: T.CPP                      |
>|    case 1:       | Compiling: EDITOR   T.CPP             |
>|                do|                                       |
>|                { |                    Total    File      |
>|                  |    Lines compiled: 13       13        |
>|                } |          Warnings: 0        0         |
>|                  |            Errors: 1        1         |
>|                wh|                                       |
>---------------------------------------------------------------------------
-
>|                  |           Ctrl-Break to quit          |
>        UNHANDLED EXCEPTION 0D at 0A47:01CD Error code: 0000
>|
> AX = 000D   BX = 0000   CX = 003B   DX = 0ED7
> SI = B47E   DI = 0000   BP = 0FCE   SP = 0FC6
> CS = 0A47   Limit =2057 segment #AF of
>C:\LAN\BC\BIN\BC.EXE________________ -
> DS = 05AF   Limit =FFFF segment #4D of C:\LAN\BC\BIN\BC.EXE9 Make  F10
Menu
> ES = 0000   Invalid segment
> SS = 05AF   Limit =FFFF segment #4D of C:\LAN\BC\BIN\BC.EXE
> - 0A47:01C5   C7 46 FC 00 00 C4 5E 0C  26 8B 47 0C 26 0B 47 0E

> You may hit [T] to terminate, but you should reboot as soon as possible,
> as the system is unstable ...

<ot>
This is not a compile error, but could be a compiler failure probably due to
previous against nature operation (some Bad Things like writing after the
bound of a buffer, or leaving a big amout of unfreed memory). When I have
this (it happens sometimes, I close the open processes, shut down and
restart the PC. If this persists, try to reinstall the compiler from scratch
(some executable could be damaged). I also do some maintenance on the disk
(scan, defrag etc...) and I erase the tcxxxxx.swp and *.dsk files .
Sometimes, the *.prj file is damaged and must be erased and recreated.
</ot>

--
-hs-
CLC-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
ISO-C Library: http://www.dinkum.com/htm_cl
"It's specified. But anyone who writes code like that should be
transmogrified into earthworms and fed to ducks." -- Chris Dollin CLC



Wed, 26 Jun 2002 03:00:00 GMT  
 Funny bug in BC 3.1

Quote:


>>/*
>>** Alright, I fixed your syntax error.
>>** Now tell us, what is the funny bug.
>>** You never said what it was.

>Because I supposed you to check it yourself :-)
>The compiler (Borland C++ 3.1) hangs when trying to compile
>the (original) code treated as C++ code. Only compiling, not running.

Since you posted this to comp.lang.c I doubt whether anybody
would have even considered trying to compile it as C++. If you
want to discuss C++ you'll need to post to a C++ related newsgroup
such as comp.lang.c++, it simply isn't relevant here.

--
-----------------------------------------


-----------------------------------------



Wed, 26 Jun 2002 03:00:00 GMT  
 Funny bug in BC 3.1

Quote:

>In comp.lang.c, it's usually best not to assume that people necessarily
>have the same compiler as you.

>> The compiler (Borland C++ 3.1) hangs when trying to compile
>> the (original) code treated as C++ code. Only compiling, not running.

>This belongs in a Borland newsgroup IMHO.

OK OK. Unfortunately I couldn't find a group comp.lang.c.borland,
only comp.lang.Pascal.borland. And I think that posting the code
to that group would be even less appropriate.

My previous post clearly explained: the problem occurs only
and only if this speficic code is compiled with Borland C++
version 3.1. So I did not expect anybody to try it with
another compiler... The code doesn't have anything to do
with classes and objects, so I posted it to the .c, not .c++
group.

It seems that nobody except me had this problem with BC.
Very strange. Anyway, I suggest EOT.

Regards
Piotr



Wed, 26 Jun 2002 03:00:00 GMT  
 Funny bug in BC 3.1


Quote:


> >This belongs in a Borland newsgroup IMHO.

> OK OK. Unfortunately I couldn't find a group comp.lang.c.borland,
> only comp.lang.pascal.borland. And I think that posting the code
> to that group would be even less appropriate.

Try borland.public.cpp.language or (possibly) borland.public.cpp.ide - I'm
not sure which of those two is most relevant here - I suspect the latter
BICBW.

--
Richard Heathfield

"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.

"Using an undefined-behavior-induced crash as a program's intended
error-checking mechanism strikes me as a spectacularly misguided strategy"
- Steve Summit, 7 Jan 2000.



Wed, 26 Jun 2002 03:00:00 GMT  
 Funny bug in BC 3.1

Quote:
>Do you really have a version that does not crash? Here is the code
>again (save it as test.cpp):

Are you trying to say to a regular of CLC to play with a C++ compiler ?
Ok let's go...

<code snipped>

<ot>
*** Bug confirmed ***.
(And it's not funny :-( )

I have no idea what happens here. Ask a Borland newsgroup, specially where
the guys of TeamB are, at

borland.public.cpp.language

You also can try to do a bug report to Inprise, but as this product is no
more supported, I guess that the result will be void...
</ot>

--
-hs-
CLC-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
ISO-C Library: http://www.dinkum.com/htm_cl
"It's specified. But anyone who writes code like that should be
transmogrified into earthworms and fed to ducks." -- Chris Dollin CLC



Thu, 27 Jun 2002 03:00:00 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Bug in BC 3.1

2. Bug in BC 3.1

3. Possible bug in BC 3.1: ellipsis in proto argument list

4. BC 3.1 FAR HEAP!

5. HELP: BC 3.1 DGROUP Problem

6. looking for bc 3.1 port of gnu's regex

7. BC 3.1 (HELP files)

8. Phar Lap's 286|DOS-Extender Lite for BC 3.1/4.0

9. Easy BC 3.1 question

10. BC 3.1 FAR HEAP!

11. BC 2.0 - Prob Running BCX with WIN 3.1

12. BC 3.1 watch problem

 

 
Powered by phpBB® Forum Software