Possible bug in BC 3.1: ellipsis in proto argument list 
Author Message
 Possible bug in BC 3.1: ellipsis in proto argument list

Forgive me if this is a FAQ (probably isn't) or if this question has
been asked before.

I seem to have found a bug in my Borland C++ 3.1 compiler.  I narrowed
the problem down to the following prototype:

void foo(...)

If the above line is by itself in foo.h and I run:
bcc -P -c foo.h
It compiles without mishap.  If you're wondering: -P is to force a C++
compile and -c is compile to .obj only.

The problem is that if I try to compile without the -P, that is,
compile in regular, standard BC 3.1, I get the error message:
) expected

This is no big deal- I can just compile with the C++ option all the
time, but regular BC should be able to compile a prototype with just
an ellipsis in the argument list without a problem- I think.  I guess
my real question is: Does BC 3.1 have a bug?  My bcc.exe is dated
6-10-92 at 03:10a.  If there is a patch floating around somewhere
could someone let me know where to ftp it from.  I checked simtel20
under the borland directory and I already have all the patches for 3.1
installed that are there.  I'd like to avoid calling Borland if someone
else has already found this problem.

I need to use the prototype as shown above, so changing it in some way
will do me no good.

If you have an answer, email to me would be great.  If this is not
possible for some reason, a post is ok.  I'll check for the answer
over the next couple of days.

Thanks.

Steve Gilbert



Thu, 13 Jul 1995 13:00:36 GMT  
 Possible bug in BC 3.1: ellipsis in proto argument list

Quote:
>I seem to have found a bug in my Borland C++ 3.1 compiler.  I narrowed
>the problem down to the following prototype:
>void foo(...)
>If the above line is by itself in foo.h and I run:
>bcc -P -c foo.h
>It compiles without mishap.  If you're wondering: -P is to force a C++
>compile and -c is compile to .obj only.
>The problem is that if I try to compile without the -P, that is,
>compile in regular, standard BC 3.1, I get the error message:
>) expected

The compiler is correct.  This reflects a difference between C and C++.

In Standard C, a function must have at least one argument declared before
the ellipsis.  On the other hand, you may declare a function with
completely unspecified arguments by using empty parens.  In C++, the
empty parens mean the function takes no arguments.  To say a function
has completely unspecified arguments in C++, use just the ellipsis.
Examples:

        void f1(int, ...);  /* C and C++: f1 takes one int plus other
                                unpsecified args */

        void f2();      /* C: no data about the arguments to f2 */
                        /* C++: f2 takes no arguments */

        void f3(...);   /* C++: no data about the arguments to f3 */
                        /* C: illegal */

You can't write function f3 in C++, although you can declare it.  There is
no (portable) way to retrieve arguments when only an ellipsis is declared.
You need to use the <stdarg.h> macros which require a declared argument.
If you try to use the C trick of defining the real function with its real
arguments, your program won't link, since foo(...) and foo(int), for
example, are different functions.  The ellipsis-only notation is to allow
linking to functions written in another language (not C++) where the
calling conventions just happen to work and you are willing to forgo type
checking and default promotion of actual arguments.
--




Fri, 14 Jul 1995 00:16:12 GMT  
 Possible bug in BC 3.1: ellipsis in proto argument list

Quote:

>...  The ellipsis-only notation
        [ void foo(...); ]
> is to allow
>linking to functions written in another language (not C++) where the
>calling conventions just happen to work and you are willing to forgo type
>checking and default promotion of actual arguments.

I meant to say
"...forgo type checking and accept default promotion of actual arguments."
                            ^^^^^^

Quote:
>--


--




Sat, 15 Jul 1995 00:47:22 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Bug in BC 3.1

2. Bug in BC 3.1

3. Funny bug in BC 3.1

4. UPDATE: Possible NASTY bug in Borland C++ 3.1 compiler

5. Possible NASTY bug in Borland C++ 3.1 code generation

6. Possible Borland 3.1 bug

7. calling unmanaged function with variable list of arguments (ellipses) failed

8. BC 3.1 FAR HEAP!

9. HELP: BC 3.1 DGROUP Problem

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

11. BC 3.1 (HELP files)

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

 

 
Powered by phpBB® Forum Software