 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Kamil Burzynski Guest
|
Posted: Fri Nov 21, 2003 12:53 am Post subject: Weird syntax - question |
|
|
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 ]
|
|
| Back to top |
|
 |
Matt Seitz Guest
|
Posted: Fri Nov 21, 2003 6:24 am Post subject: Re: Weird syntax - question |
|
|
Kamil Burzynski wrote:
| Quote: | I've recently found such syntax working in GCC (2.9x & 3.x):
#include
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 ]
|
|
| Back to top |
|
 |
Vincent Leloup Guest
|
Posted: Fri Nov 21, 2003 8:38 am Post subject: Re: Weird syntax - question |
|
|
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 (AT) nospam (DOT) com> a écrit dans le message de
news:slrn.pl.brova8.108.nospam (AT) KBURZYNSKI1 (DOT) adb.pl...
| Quote: | Hello.
I've recently found such syntax working in GCC (2.9x & 3.x):
#include
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 ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|