Topic: Weird syntax - question


Author: nospam@nospam.com (Kamil Burzynski)
Date: Fri, 21 Nov 2003 00:53:40 +0000 (UTC)
Raw View
Hello.

 I've recently found such syntax working in GCC (2.9x & 3.x):

#include <iostream>
using namespace std;

int a = 1;
int b = 2;

void foo( int c( a + b ) )
{
 cout << c << endl;
}

int main()
{
 foo();

 return( 0 );
}

Strangely enough - this compiles and works. foo() is considered as
parameterless: foo( 1 ) is invalid call then.

Borland 5.5 compiler does not pass this code - which _strongly_ suggest
that its rather GCC bug than standard feature.

Any ideas/comments?

--
Best regards from
Kamil Burzynski

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: metadata@sbcglobal.net (Matt Seitz)
Date: Fri, 21 Nov 2003 06:24:43 +0000 (UTC)
Raw View
Kamil Burzynski wrote:
>  I've recently found such syntax working in GCC (2.9x & 3.x):
>
> #include <iostream>
> using namespace std;
>
> int a = 1;
> int b = 2;
>
> void foo( int c( a + b ) )
> {
>  cout << c << endl;
> }
>
> int main()
> {
>  foo();
>
>  return( 0 );
> }

Comeau's online compiler (http://www.comeaucomputing.com/tryitout) reports:

Comeau C/C++ 4.3.3 (Aug  6 2003 15:13:37) for ONLINE_EVALUATION_BETA1
Copyright 1988-2003 Comeau Computing.  All rights reserved.
MODE:strict errors C++

"ComeauTest.c", line 7: error: variable "a" is not a type name
   void foo( int c( a + b ) )
                    ^

"ComeauTest.c", line 7: error: expected a ")"
   void foo( int c( a + b ) )
                      ^

"ComeauTest.c", line 14: error: too few arguments in function call
    foo();
        ^

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: vincent_leloup@yahoo.fr ("Vincent Leloup")
Date: Fri, 21 Nov 2003 08:38:03 +0000 (UTC)
Raw View
Other GCC version not tried but with gcc 3.3.1 this example does not work:
"8: error variable declaration is not allowed here
:In function `void foo()':
9: error: `c' undeclared (first use in this function)"

Perhaps a bug corrected in version 3.3.1.

Vincent Leloup


"Kamil Burzynski" <nospam@nospam.com> a    crit dans le message de
news:slrn.pl.brova8.108.nospam@KBURZYNSKI1.adb.pl...
> Hello.
>
>  I've recently found such syntax working in GCC (2.9x & 3.x):
>
> #include <iostream>
> using namespace std;
>
> int a = 1;
> int b = 2;
>
> void foo( int c( a + b ) )
> {
> cout << c << endl;
> }
>
> int main()
> {
> foo();
>
> return( 0 );
> }
>
> Strangely enough - this compiles and works. foo() is considered as
> parameterless: foo( 1 ) is invalid call then.
>
> Borland 5.5 compiler does not pass this code - which _strongly_ suggest
> that its rather GCC bug than standard feature.
>
> Any ideas/comments?
>
> --
> Best regards from
> Kamil Burzynski
>
> ---
> [ comp.std.c++ is moderated.  To submit articles, try just posting with ]
> [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
> [              --- Please see the FAQ before posting. ---               ]
> [ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]
>


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]