Return-Path: X-Original-To: apmail-stdcxx-dev-archive@www.apache.org Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 831389E53 for ; Mon, 11 Jun 2012 16:35:34 +0000 (UTC) Received: (qmail 74627 invoked by uid 500); 11 Jun 2012 16:35:34 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 74557 invoked by uid 500); 11 Jun 2012 16:35:33 -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 74548 invoked by uid 99); 11 Jun 2012 16:35:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Jun 2012 16:35:33 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of msebor@gmail.com designates 209.85.210.54 as permitted sender) Received: from [209.85.210.54] (HELO mail-pz0-f54.google.com) (209.85.210.54) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Jun 2012 16:35:24 +0000 Received: by dadv36 with SMTP id v36so5219696dad.41 for ; Mon, 11 Jun 2012 09:35:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; bh=IUfWyQhsFuwWil9sT8yPnLPq8Y9TrJ8W6/ts8On6raQ=; b=ZT1FMhDWzIGJ8NyB4L93oQKFo9ngZg/IjEvvaX0RSXOqEjI5xJSgm7sITP54Rzl7tQ Y3yJgpXQ5H576klhqnP3sf5ltVh6HBYDttZM3hiS/n8IolILHAfQRcJjiQEc1Tnqq1W4 683g/5b0VeVyBaFHV2hDxZZnbEIS6s6ucHnJvGAwr0y6wu4DqW5mS19goemQ1bRpcVEX YEAdV5uEAZ/cJVdSiHIYuoeIjoZvORttkr3xjjsQ6lMizqWheYkRQZCFKJrjntHbiLZX gWE16/qrxqHYz5O5OjOUxbGmWj+/cC3H3IivZhlRqfKIUoJgqzQwXIhkB77wmZSg0sHG nhZA== Received: by 10.68.230.68 with SMTP id sw4mr18976540pbc.142.1339432502943; Mon, 11 Jun 2012 09:35:02 -0700 (PDT) Received: from localhost.localdomain (72-163-0-129.cisco.com. [72.163.0.129]) by mx.google.com with ESMTPS id ms1sm18959255pbb.63.2012.06.11.09.35.02 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 11 Jun 2012 09:35:02 -0700 (PDT) Message-ID: <4FD61E35.6090702@gmail.com> Date: Mon, 11 Jun 2012 10:35:01 -0600 From: Martin Sebor User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 MIME-Version: 1.0 To: dev@stdcxx.apache.org CC: Stefan Teleman Subject: Re: [jira] [Updated] (STDCXX-1058) std::basic_ios<>::copyfmt() with registered callback (via std::ios_base::register_callback()) run-time SIGABRT References: <330482791.12512.1328421173597.JavaMail.tomcat@hel.zones.apache.org> <1431222055.10784.1335292293596.JavaMail.tomcat@hel.zones.apache.org> <53D52D02E87FA04A948D9A74A7AE617C11B358D02F@Eagle.Blue.Roguewave.Com> <4FB3F8D6.3070007@gmail.com> <4FB52024.4080005@gmail.com> In-Reply-To: Content-Type: multipart/mixed; boundary="------------060905090202090707010207" --------------060905090202090707010207 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ... > OK I attached a new test case - 27.basic_ios.copyfmt.stdcxx-1058.cpp. > > But, using a simple derived class from std::basic_ios doesn't trigger > the bug. It's only triggered when using std::fstream or > std::stringstream. Here's what I meant: struct A: std::streambuf { }; struct B: std::ios { A sb; B () { init (&sb); } } f0, f1; Btw., in your new test, either the TEST_ASSERT() macro should abort or the test should when before returning ret is non-zero. I.e., every regression test should report failure by calling abort (via the assert() macro). Returning a non-zero exit status (in addition to making use of assert()) is fine but it shouldn't be the sole mechanism for reporting an error. Also, please avoid #including in tests unless exercising the standard streams (std::cout et al.) The header runs complicated code and can lead to unrelated failures. Attached is a slightly modified test to show what I mean. (Also fixes formatting -- please use 4 space indents and a space before each open paren; curly brace goes on the same line as the statement except for namespace scope declarations). Martin > > --Stefan > --------------060905090202090707010207 Content-Type: text/x-c++src; name="27.ios_base.event_callback.stdcxx-1058.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="27.ios_base.event_callback.stdcxx-1058.cpp" /************************************************************************** * * 27.ios_base.event_callback.stdcxx-1058.cpp - regression test for STDCXX-1058 * * http://issues.apache.org/jira/browse/STDCXX-1058 * * $Id$ * ************************************************************************** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. * **************************************************************************/ /* * This program should run to completion and exit with return status 0 */ #include #include #include #define TEST_ASSERT(expr) \ (expr) ? ret = 0 \ : std::fprintf (stderr,"line %i: Assertion failed: %s\n", \ __LINE__, #expr) int x; void testfun (std::ios_base::event ev, std::ios_base& iosobj, int index) { x = index; switch (ev) { case std::ios_base::copyfmt_event: std::fprintf (stderr, "copyfmt_event\n"); break; case std::ios_base::imbue_event: std::fprintf (stderr, "imbue_event\n"); break; case std::ios_base::erase_event: std::fprintf (stderr, "erase_event\n"); break; default: std::fprintf (stderr, "unknown (this should never happen)\n"); break; } } int main () { struct A: std::streambuf { }; struct B: std::ios { A sb; B () { init (&sb); } } f0, f1; int i = 101; int ret = 1; std::ios_base::event_callback e1 = &testfun; f0.register_callback (e1, i); x = 0; f0.imbue (f0.getloc ()); TEST_ASSERT (x == i); x = 0; f0.copyfmt (f1); TEST_ASSERT (x == i); B s0, s1; s0.register_callback (e1, i); x = 0; s0.imbue (f0.getloc ()); TEST_ASSERT (x == i); x = 0; s0.copyfmt (s1); TEST_ASSERT (x == i); assert (ret == 0); return ret; } --------------060905090202090707010207--