From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9171 invoked by alias); 23 Jan 2002 16:46:07 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 9126 invoked by uid 71); 23 Jan 2002 16:46:03 -0000 Date: Wed, 23 Jan 2002 08:46:00 -0000 Message-ID: <20020123164603.9123.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Carlo Wood Subject: Re: c++/5467: STL problem using multithreading Reply-To: Carlo Wood X-SW-Source: 2002-01/txt/msg00836.txt.bz2 List-Id: The following reply was made to PR c++/5467; it has been noted by GNATS. From: Carlo Wood To: jjessel@amadeus.net Cc: gcc-gnats@gcc.gnu.org Subject: Re: c++/5467: STL problem using multithreading Date: Wed, 23 Jan 2002 17:38:43 +0100 On Wed, Jan 23, 2002 at 04:17:47PM -0000, jjessel@amadeus.net wrote: > >Number: 5467 You posted four Problem reports - duplicates as far as I can see. > I have isolated the following code (that I suppose to be thread safe) in order to reproduce a problem I have in a bigger program. > I try to execute it in several threads. Please provide a working example, that is: a program with main() that compiles out of the box and shows the problem. > Here is my compilation line: > g++ -g -fexceptions simple.cpp -o simple -lpthread You should use: g++ -pthread -g -fexceptions simple.cpp -o simple The option -pthread will cause the library to be thread-safe. Also, std::cout is not thread-safe (and not intended to), you need to provide a user-level lock for it. -- Carlo Wood