Return-Path: Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: (qmail 61555 invoked from network); 2 Apr 2008 17:56:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Apr 2008 17:56:06 -0000 Received: (qmail 87004 invoked by uid 500); 2 Apr 2008 17:56:06 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 86986 invoked by uid 500); 2 Apr 2008 17:56:06 -0000 Mailing-List: contact dev-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list dev@stdcxx.apache.org Received: (qmail 86977 invoked by uid 99); 2 Apr 2008 17:56:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Apr 2008 10:56:06 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of msebor@gmail.com designates 64.233.170.189 as permitted sender) Received: from [64.233.170.189] (HELO rn-out-0910.google.com) (64.233.170.189) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Apr 2008 17:55:24 +0000 Received: by rn-out-0910.google.com with SMTP id s46so1813667rnb.3 for ; Wed, 02 Apr 2008 10:55:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:organization:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; bh=mAfXazG7AEOXSQaicpSkgqP4z9ZB35URE3CmD7hp2sg=; b=G1ehyeCDUDh8neb9Zoo5MvQ9hvNJRbJkDdfi2jnyscCYZwABGcwEDsbCstZlmmGp4iGti1SbVA+6Bim6q9RGjTreFeqJHkEmnHbCt2+5n/9TbHmSP6hdDgzZae96rppbyH7PYyBQByiGtYp3ywxAL+ZxHSpeavjiPHPbmyy0QDk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=message-id:date:from:organization:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=FvPpDTa0tjuOnoZup2UHZVzmndaOnGeX9zmmGvt1ZuBVSqtdsm1jpFWhzmwB+eAz1Xf8nYQSHlXs2I+SjCSr34mg4u77+zbKO17fckP8ezrOFJd81EHfiLTaFYO2ErBP13rTH84KGg9Ct94JibjDxrUKlJ42sWbRugGjfZTvJJc= Received: by 10.114.195.19 with SMTP id s19mr15322284waf.58.1207158935246; Wed, 02 Apr 2008 10:55:35 -0700 (PDT) Received: from localhost.localdomain ( [71.229.200.170]) by mx.google.com with ESMTPS id v38sm4952095wah.7.2008.04.02.10.55.33 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 02 Apr 2008 10:55:33 -0700 (PDT) Message-ID: <47F3C894.7080301@roguewave.com> Date: Wed, 02 Apr 2008 11:55:32 -0600 From: Martin Sebor Organization: Rogue Wave Software, Inc. User-Agent: Thunderbird 2.0.0.12 (X11/20080226) MIME-Version: 1.0 To: dev@stdcxx.apache.org Subject: Re: [jira] Commented: (STDCXX-742) [IBM XLC++ 9.0/AIX 5.3] 22.locale.messages fails with assertions References: <1592939173.1207080504655.JavaMail.jira@brutus> <47F2A6C3.2000804@roguewave.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: Martin Sebor X-Virus-Checked: Checked by ClamAV on apache.org Travis Vitek wrote: > > >> Martin Sebor wrote: >> >> Travis Vitek wrote: >>> >>> >>>> Travis Vitek commented on STDCXX-742: >>>> ------------------------------------- >>>> >>>> This is happening because we don't use the -qrtti=dynamiccast >>>> option. We internally use a dynamic_cast to determine if the >>>> facet is of the correct derived type, but if dynamic_cast >>>> isn't supported we use a C style cast, and that returns bad results. >>>> >>>> This case is essentially the same as STDCXX-664. We didn't add >>>> -qrtti=dynamiccast back then, and we just worked around the >>>> issue in the test. It seems to me that we should have added >>>> the flag. Would this be a binary compatible change? >>>> >>> What are the thoughts on this? There was some discussion >>> [http://tinyurl.com/3xfdma] of enabling -qrtti=dynamiccast for the >>> VisualAge C++ compiler, but it petered out. >> Is there any way to turn on rtti using a pragma? That way we could >> enable it only for translation units that included and we >> wouldn't be shoving the option down the throats of users who don't >> care about named locales. > > No, there is no pragma for this. Even if there were we would need to do > some hacking to get it to work. We try determine if dynamic_cast<>() > exists and is functioning correctly at configuration time. If that > config test fails, we define _RWSTD_NO_DYNAMIC_CAST. So even if we > managed to enable rtti when was included, we would need to > 'fix' the _RWSTD_NO_DYNAMIC_CAST and _RWSTD_DYNAMIC_CAST macros. Ewww.. Or just add a special implementation just for XLC++. But sounds like that's not possible anyway. > >> Btw., does XLC++ itself correctly handle the test case mentioned >> in the thread, even without -qrtti? (It's possible to get some >> simple cases to work even w/o the option but not all of them). >> > > I'm not absolutely sure what you're asking. It sounds like you are > asking if the Standard C++ Library implementation that ships with XLC++ > has this same problem. That's exactly what I was asking, thanks. > The answer to that is no... I wonder if it would get this right: struct MyMessages: std::messages { }; assert (!std::has_facet(std::locale::classic ())); If not, they probably have their own simple version of "RTTI" built into the facet (e.g., via a virtual function) but they still can't handle tricky cases like this one. Unfortunately, we can't even do this much w/o breaking binary compatibility. All in all, I'm still not sure this fairly obscure corner case is worth the effort of adding a compiler option for. C++ locales are used by only a small community of users, and I suspect that this case (calling has_facet or use_facet with a facet derived from one of the standard ones) is unlikely to come up even in their "advanced" uses. I say we open an issue for this just for the record and keep deferring it until we feel like adding the option or until IBM decides to enable RTTI by default. Martin > > $ type t.cpp > #include > #include > #include > > template > void test_has_facet (const char *loc_name, const char *cname) > { > const std::locale loc = > loc_name ? std::locale (loc_name) : std::locale (); > > typedef std::messages_byname ByName; > > const bool byname = loc_name > && std::strcmp (loc_name, "C"); > > const bool facet_exists = std::has_facet(loc); > > assert (byname == facet_exists); > > try { > // verify that use facet throws an exception only > // for the default and "C" locales > std::use_facet(loc); > > assert (byname); > } > catch (std::exception &ex) { > assert (!byname); > } > } > > template > void test_messages (charT, const char *cname) > { > // exercise has_facet and use_facet in the default locale > test_has_facet(0, cname); > > // exercise has_facet and use_facet in locale("C") > test_has_facet("C", cname); > } > > int main (int, char*[]) > { > test_messages (char (), "char"); > > return 0; > } > > $ xlC t.cpp -o t && ./t > $ > > If I run the same code under stdcxx, I get the following > > $ gmake t && ./t > > > > Assertion failed: byname == facet_exists, file t.cpp, line 18 > IOT/Abort trap (core dumped) > $ > > Travis >