On 9 Aug, 01:48, Walter Bright <newshou...@digitalmars.com> wrote:
> Digital Mars C++ is very fast at compiling, far faster
> than any other C++ compiler.
I have tested free Digital Mars C/C++ Compiler v. 8.52 from
http://www.digitalmars.com/download/freecompiler.html
The results were impressive, so I decided to show here how well this
fastest compiler works.
1)
namespace
{
struct X {};
}
int main()
{
::X x; // well-formed
}
Compiler message:
Error: undefined identifier 'X', did you mean 'X'?
2)
struct X
{
void f(X) {}
};
int main()
{
f(X()); // ill-formed
}
No diagnostics issued (the compiler silently calls X::f).
3)
struct X
{
typedef X *type;
friend void f(type)
{
type t; // well-formed
}
};
int main() {}
Compiler message:
Error: '(' expected following simple type name
4)
int main()
{
int arr[10] = {}; // well-formed
}
Compiler message:
Error: expression expected
5)
struct X {};
int main()
{
X f(X()); // f shall be a function, not a variable
int size = sizeof f(0); // well-formed
}
Compiler message:
Error: no match for function 'operator()(int )'
6)
template <class T>
struct X
{
template <class U>
void f();
};
template <class T>
template <class U>
void X<T>::f() {} // well-formed
int main()
{
X<void>().f<int>(); // well-formed
}
Compiler message:
Error: template-argument 'U' has no value in template function
specialization
7)
#include <stdio.h>
struct A
{
typedef A type;
A() { printf("A()\n"); }
};
template <class T>
struct X
{
void f()
{
typename T::type(); // well-formed
}
};
int main()
{
X<A>().f();
}
Compiler message:
Error: identifier or '( declarator )' expected
8)
template <class T, void (T::*)(T &)>
struct X {};
template <class T>
void f(X<T, &T::swap>) {} // well-formed
int main() {}
Compiler message:
Error: can't take address of register, bit field, constant or string
Internal error: func 564
9)
#include <stdio.h>
template <class T>
struct identity {};
typedef char b0[1];
typedef char b1[2];
template <class U>
b0 &test(...);
template <class U>
b1 &test(identity<typename U::type> *);
template <class T>
struct has_type
{
enum { value = sizeof test<T>(0) == sizeof(b1) };
};
int main()
{
printf("%d\n", has_type<int>::value);
}
Compiler message:
Internal error: template 1932
10)
template <class T>
void f(T &) {}
void g() {}
int main()
{
f(g); // well-formed
}
Compiler message:
Error: reference must refer to same type or be const
Had: void (*C func)()
and: void (*C func)()&
11)
void f(int &) {}
void f(int const &) {}
int main()
{
f(0); // well-formed: shall call the second f
}
Compiler message:
Error: reference must refer to same type or be const
Had: int
and: int &
12)
void f(int const *) {}
void f(int *const &) {}
int main()
{
int *p = 0;
f(p); // well-formed: shall call the second f
}
Compiler message:
Error: ambiguous reference to symbol
Had: f(int const *)
and: f(int *const &)
13)
struct X
{
X() {}
private:
X(X const &);
};
int main()
{
X x = X(); // ill-formed (even if the copy would be elided)
// this error is required to be diagnosed
}
No diagnostics issued.
14)
#include <stdio.h>
struct B {};
struct D : B
{
D() { printf("D()\n"); }
~D() { printf("~D()\n"); }
};
int main()
{
B const &ref = D();
printf("ref scope\n");
}
Program output:
D()
~D()
ref scope
Required program output:
D()
ref scope
~D()
15)
#include <stdio.h>
#include <typeinfo>
struct B
{
virtual ~B() {}
};
int main()
{
B *b = 0;
try
{
printf("%s\n", typeid(*b).name()); // see [expr.typeid]/2
}
catch (std::bad_typeid &)
{
printf("bad typeid\n");
}
}
Program output: none (crash)
Required program output:
bad typeid
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
According to C++98 & C++03 rules, there are also alternative
permissible variants of the program output - there may be additional
calls to the destructor of class D if the reference is bound to a copy.
Yes, it really is fast, Walter knows his stuff. I vaguely recall that he was the
one behind the Zortech C++ compiler? So, if you have the time, try D. :-)
Anyways, unless you used a direct link to the download you would have clicked
your way through a page that says
The Software is not generally available software. It has not undergone
testing and may contain errors. The Software was not designed to operate
after December 31, 1999.
It's only now, as of ten years after that, that major compiler vendors have
finally caught up with most of the 1998 Holy Standard.
You could as well have tried out Borland C++ 5.0 (Borland also fast!).
It's a good idea to read what one clicks through (my mother has this problem of
not actually reading, and gets into all kinds of computer problems, "Help!"...).
Cheers & hth.,
- Alf ;-)
--
blog at <url: http://alfps.wordpress.com>
But fighting with compiler bugs is probably not.
> So, if you have the time, try D. :-)
This programming language is not interesting for me.
> Anyways, unless you used a direct link to the download you would have clicked
> your way through a page that says
>
> The Software is not generally available software. It has not undergone
> testing and may contain errors. The Software was not designed to operate
> after December 31, 1999.
>
> It's only now, as of ten years after that, that major compiler vendors have
> finally caught up with most of the 1998 Holy Standard.
I don't see any reasons to provide a link to this free compiler other
than for testing. Why should a potential user buy the general product
if the trial version is so bad? Is the general compiler much better?
--
It's the same compiler. The general product includes things like the IDE,
debugger, library source, etc.
Thanks for the bug reports. I have taken the liberty of putting them
into the
C++ bugzilla:
http://bugzilla.digitalmars.com/issues/show_bug.cgi?id=65
[...]
http://bugzilla.digitalmars.com/issues/show_bug.cgi?id=78
May I ask what test suite you were using?
I didn't use any professional test suite. I just wrote and tested
small set of short programs.