www.digitalmars.com         C & C++   DMDScript  

c++.stl - Scott Meyers Test

reply Mark Evans <Mark_member pathlink.com> writes:
Scott Meyers, author of "Effective STL," wonders whether DMC can compile this
very small program.  -M.

const class {
public:
template <class T>
operator T*() const {return 0;}

template <class C, class T>
operator T C::*() const {return 0;}

} null = {};

class A {
public:
int  f (char, int);
int  f (char, double);
void f (const char *) const;
};

class B {};

int main() {
int (A::*pmf)(char, int) = &A::f;
pmf = null;
int (A::*pmf2)(char, double) = &A::f;
pmf2 = null;
void (A::*pmf3)(const char*) const = &A::f;
pmf3 = null;

void (B::*pmf4)() const = null;
}
Jul 25 2002
parent reply Cesar Rabak <csrabak uol.com.br> writes:
Mark Evans wrote:
 
 Scott Meyers, author of "Effective STL," wonders whether DMC can compile this
 very small program.  -M.
 
[snipped] Just wondering: can't Mr. Meyers check this by himself? -- Cesar Rabak GNU/Linux User 52247. Get counted: http://counter.li.org/
Jul 25 2002
parent reply Mark Evans <Mark_member pathlink.com> writes:
I enticed the guy maintaining Meyer's Effective STL code to start using DMC in
his test suites.

Meyers sent this test case to me, and I thought that if any bugs resulted from
it, then they should be public.  I also thought that Walter might just glance at
it and say "no that's not supported yet" or "yes it should work" or "yes it does
work."

I just tried it with the latest beta release and got errors as follows.  I did
not use any compiler flags.
M.

==========================
C:\dm\bin>scppn e:\test\meyerstest.cpp
} null = {};
^
e:\test\meyerstest.cpp(9) : Error: malformed template declaration
pmf = null;
^
e:\test\meyerstest.cpp(22) : Error: undefined identifier 'null'
pmf2 = null;
^
e:\test\meyerstest.cpp(24) : Error: need explicit cast to convert
from: int
to  : int ( A::*member func)(char ,double )
pmf3 = null;
^
e:\test\meyerstest.cpp(26) : Error: need explicit cast to convert
from: int
to  : void ( A::*member func)(char const *)const
void (B::*pmf4)() const = null;
^
e:\test\meyerstest.cpp(28) : Error: need explicit cast to convert
Fatal error: too many errors
Jul 25 2002
next sibling parent reply "Walter" <walter digitalmars.com> writes:
Yes, it doesn't work at the moment. I don't know how much work it would be
to fix it. -Walter

"Mark Evans" <Mark_member pathlink.com> wrote in message
news:ahpshu$j42$1 digitaldaemon.com...
 I enticed the guy maintaining Meyer's Effective STL code to start using
DMC in
 his test suites.

 Meyers sent this test case to me, and I thought that if any bugs resulted
from
 it, then they should be public.  I also thought that Walter might just
glance at
 it and say "no that's not supported yet" or "yes it should work" or "yes
it does
 work."

 I just tried it with the latest beta release and got errors as follows.  I
did
 not use any compiler flags.
 M.
Jul 25 2002
parent reply Mark Evans <Mark_member pathlink.com> writes:
Microsoft Visual C++ 6 Service Pack 5 also bombs on this test case.

M.

--------------------Configuration: MeyersTest - Win32 Debug--------------------
Compiling...
MeyersTest.cpp
e:\test\meyerstest.cpp(9) : error C2059: syntax error : '}'
e:\test\meyerstest.cpp(9) : error C2143: syntax error : missing ';' before '}'
e:\test\meyerstest.cpp(9) : error C2143: syntax error : missing ';' before '}'
e:\test\meyerstest.cpp(22) : error C2440: '=' : cannot convert from 'const class
' to 'int (__thiscall A::*)(char,int)'
No user-defined-conversion operator available that can perform this conversion,
or the operator cannot be called
e:\test\meyerstest.cpp(24) : error C2440: '=' : cannot convert from 'const class
' to 'int (__thiscall A::*)(char,double)'
No user-defined-conversion operator available that can perform this conversion,
or the operator cannot be called
e:\test\meyerstest.cpp(26) : error C2440: '=' : cannot convert from 'const class
' to 'void (__thiscall A::*)(const char *) const'
No user-defined-conversion operator available that can perform this conversion,
or the operator cannot be called
e:\test\meyerstest.cpp(28) : error C2440: 'initializing' : cannot convert from
'const class ' to 'void (__thiscall B::*)(void) const'
No user-defined-conversion operator available that can perform this conversion,
or the operator cannot be called
e:\test\meyerstest.cpp(29) : warning C4508: 'main' : function should return a
value; 'void' return type assumed
Error executing cl.exe.

MeyersTest.obj - 7 error(s), 1 warning(s)
Jul 25 2002
parent reply "Walter" <walter digitalmars.com> writes:
"Mark Evans" <Mark_member pathlink.com> wrote in message
news:ahq3mi$qqv$1 digitaldaemon.com...
 Microsoft Visual C++ 6 Service Pack 5 also bombs on this test case.
Must be one of those compiler torture tests <g>.
Jul 26 2002
parent reply Mark Evans <Mark_member pathlink.com> writes:
Walter just advised me that the latest beta 8.29.19 successfully compiles the
code.

And it only took Walter a couple days to fix.  That must be some really good C++
compiler code.

Thank you Walter for your usual prompt action.

-M.
Jul 29 2002
parent Heinz Saathoff <hsaat bre.ipnet.de> writes:
Mark Evans schrieb...
 
 And it only took Walter a couple days to fix.  That must be some really good
C++
 compiler code.
And a real good programmer too! - Heinz
Jul 29 2002
prev sibling parent reply Cesar Rabak <csrabak uol.com.br> writes:
Mark Evans wrote:
 
 I enticed the guy maintaining Meyer's Effective STL code to start using DMC in
 his test suites.
I see. Is the code supposed to be inherently compiler agnostic or are there #ifdefs here and there to support several compilers? -- Cesar Rabak GNU/Linux User 52247. Get counted: http://counter.li.org/
Jul 25 2002
parent reply Mark Evans <Mark_member pathlink.com> writes:
It's just one of Scott Meyer's pet test programs -- what he calls a "standard"
program meaning that anything claiming to handle C++ should handle it without
modification.

He says that Borland and Comeau handle this particular case, and my reply was:

"But I can practically guarantee that there exists, in the space of all
possible C++ programs, cases which DMC compiles that those two do not.

Still you are right Borland and Comeau are good."

Mark
Jul 25 2002
parent Mark Evans <Mark_member pathlink.com> writes:
(Those STL gurus were also confused about <iostream> support in DMC and that was
another mark against it in their minds.  -M.)
Jul 25 2002