www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Google C++ needs for Clang

reply bearophile <bearophileHUGS lycos.com> writes:
A new nice post in the LLVM blog, about Clang improvements driven by Google C++
programming needs:

http://blog.llvm.org/2011/05/c-at-google-here-be-dragons.html

http://www.reddit.com/r/programming/comments/hibd6/google_extending_clang_c_to_emit_better_more/

Quotations from the blog post:

This is the first time I read something like this about trying to improve
programmers productivity:

As a performance junky, I like to think of this in familiar terms. It’s
analogous to an algorithmic performance improvement. You get “algorithmic”
improvements in productivity when you reduce the total work required for an
engineer to get the job done, or fundamentally shift the time scale that the
work requires. However, improving the time a single task requires often runs
afoul of all the adages about performance tuning, 80/20 rules, and the pitfalls
of over-optimizing.<

Later it says: long kMaxDiskSpace = 10 << 30; // Thirty gigs ought to be enough for anybody. ... Which now trigger the following errors: example2.cc:12:25: error: shift result (10737418240) requires 35 bits to represent, but 'int' only has 32 bits [-Werror,-Wshift-overflow] long kMaxDiskSpace = 10 << 30; ~~ ^ ~~ D/DMD is not modern/intelligent/good enough to catch this common error yet, this gives no errors nor warnings in D2: int kMaxDiskSpace = 10 << 30; void main() {} I hope to see D lose its rusted chains and improve on this :-) Bye, bearophile
May 23 2011
parent reply Adam D. Ruppe <destructionator gmail.com> writes:
 D/DMD is not modern/intelligent/good enough to catch this common
 error yet, this gives no errors nor warnings in D2:

If you write the literal though, you do get the error: int kMaxDiskSpace = 10737418240; test66.d(6): Error: cannot implicitly convert expression (10737418240L) of type long to int This might be a bug in the compiler's constant folding, since it catches one form but not the other. The other two errors in that blog are done by D right now, despite it being obsolete, stupid, and not good enough yet.
May 23 2011
next sibling parent bearophile <bearophileHUGS lycos.com> writes:
Adam D. Ruppe:

 The other two errors in that blog are done by D right now, despite
 it being obsolete, stupid, and not good enough yet.

See also the -fcatch-undefined-behavior, -ftrapv and (the removed) -ftrapu Clang switches: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=136205 http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=136717 Bye, bearophile
May 23 2011
prev sibling parent reply Don <nospam nospam.com> writes:
Adam D. Ruppe wrote:
 D/DMD is not modern/intelligent/good enough to catch this common
 error yet, this gives no errors nor warnings in D2:

If you write the literal though, you do get the error: int kMaxDiskSpace = 10737418240; test66.d(6): Error: cannot implicitly convert expression (10737418240L) of type long to int This might be a bug in the compiler's constant folding, since it catches one form but not the other. The other two errors in that blog are done by D right now, despite it being obsolete, stupid, and not good enough yet.

Range propagation is not implemented yet, except for a couple of simple cases. (Bearophile -- do you actually know that? You've made many posts on similar topics, which suggest all sorts of problems, but it's just not implemented yet).
May 24 2011
parent Adam D. Ruppe <destructionator gmail.com> writes:
Don wrote:
 Range propagation is not implemented yet, except for a couple of
 simple cases.

I didn't realize that... those simple cases seem to do a fairly decent job!
May 24 2011