Article View: gnu.g++.bug
Article #2143Bugs in C GNU C++
From: XITITKUN%DDATHD21.BITNET
Date: Tue, 09 Jan 1990 13:40
Date: Tue, 09 Jan 1990 13:40
66 lines
1930 bytes
1930 bytes
We are currently using the GNU C++ compiler version 1.34.2.
While using the compiler I discovered the following two
problems:
1) The sample program
#include <stdio.h>
main()
{
printf("SIZE: %d\n", sizeof( typeof(int[3]) ) );
}
compiles and produces the expected output: `SIZE: 12'.
I would expect the following similar program to produce
an output like `SIZE: 4', but actually, the program doesn't
compile at all.
#include <stdio.h>
main()
{
printf("SIZE: %d\n", sizeof(typeof(* typeof(int[3]) ) ) );
}
Starting the compiler with: bin/g++ demo.cc -o demo
results in the following error message:
In function int main ():
demo.cc:5: parse error before `)'
2) Initializing a struct parameter with a default value doesn't work,
though I could find nothing in the documentation which tells me that
this is not supposed to work. The following sample program
#include <stdio.h>
struct example
{ int a;
float b;
};
void dummy(example demo ={5, 3.1415})
{ printf("Result: %d %f\n", demo.a, demo.b);
}
main()
{ example yyy;
example xxx = {1, 1.0};
dummy( yyy );
dummy();
dummy( xxx );
}
was compiled with: bin/g++ demo.cc -o demo
and produced the following result:
Result: 0 0.000000
Result: 0 0.000000
Result: 1 1.000000
instead of:
Result: 0 0.000000
Result: 5 3.141400
Result: 1 1.000000
which I think is the correct answer.
Thomas Kunz XITITKUN@DDATHD21.BITNET
,
Technical Details
Message-ID:
<9001091340.AA11043@life.ai.mit.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!MITVMA.MIT.EDU!XITITKUN%DDATHD21.BITNETShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!MITVMA.MIT.EDU!XITITKUN%DDATHD21.BITNET From: XITITKUN%DDATHD21.BITNET@MITVMA.MIT.EDU Newsgroups: gnu.g++.bug Subject: Bugs in C GNU C++ Message-ID: <9001091340.AA11043@life.ai.mit.edu> Date: 9 Jan 90 13:40:31 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 66 X-Unparsable-Date: Dienstag, 9. Januar 1990, 14.33 Uhr und 13 Sekunden MEZ