From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ab1d177a5a26577d X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Received: by 10.68.27.230 with SMTP id w6mr3720834pbg.3.1317909671919; Thu, 06 Oct 2011 07:01:11 -0700 (PDT) Path: lh7ni12841pbb.0!nntp.google.com!news1.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx01.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit3.readnews.com!s09-11.readnews.com!unm2.readnews.com.POSTED!not-for-mail X-Trace: DXC=WlA`hM_M<5Qh=7;Md4]1[_TLaYZ5A`]3W]UVm4ab0o;_k`R^3PKYWgSDJ?JI0Tj8>\EJ:[0jkND`_VjKk:Lk^BNQcR12TN^Bg7^?XWF3LDYS9R X-Complaints-To: abuse@usenet-news.net Date: Thu, 06 Oct 2011 10:01:10 -0400 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: What's wrong with C++? References: <1ee1a434-4048-48f6-9f5e-d8126bebb808@r19g2000prm.googlegroups.com> In-Reply-To: Message-ID: <4e8db4a7$0$28634$a8266bb1@newsreader.readnews.com> Organization: readnews.com - News for Geeks and ISPs NNTP-Posting-Host: 63767864.newsreader.readnews.com Xref: news1.google.com comp.lang.ada:18331 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: 2011-10-06T10:01:10-04:00 List-Id: On 10/6/2011 9:19 AM, Peter C. Chapin wrote: > On Wed, 05 Oct 2011 04:13:22 +0200, Yannick DuchĂȘne (Hibou57) wrote: > The C++ compilers I've used where I've seen this happen (mostly while > experimenting with metaprogramming) all produced an error message about > "template instantiation depth exceeded" or something like that. None of > them silently produced incorrect code. I have unfortunately had the opposite experience with an older version of Sun CC for Sparc. I was doing a kind of template "recursion" as in the following code: struct Nil { }; template struct Cons { First first; Rest rest; }; template void do_something(T) { } inline void apply_do_something(Nil) { } template inline void apply_do_something(Cons object) { do_something(object.first); apply_do_something(object.rest); } The idea is that you build up a nested Cons structure of the types you want to store, and then calling iterate on an object of that type generates an inline expansion resulting in an unrolled call of the do_something method on each field of the structure, with no actual recursion at runtime. Unfortunately, when my structure got nested too deeply, the compiler silently terminated the recursion with an 'int'! It took some strenuous debugging to figure that out, and I had to abandon this approach altogether.