From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 85177 invoked by alias); 28 Mar 2017 15:40:11 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 85159 invoked by uid 89); 28 Mar 2017 15:40:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f50.google.com Received: from mail-wm0-f50.google.com (HELO mail-wm0-f50.google.com) (74.125.82.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 28 Mar 2017 15:40:09 +0000 Received: by mail-wm0-f50.google.com with SMTP id u132so43055425wmg.0 for ; Tue, 28 Mar 2017 08:40:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=3IsO42wR1IVgVIRqwPr4GKKatBahtfePzbZpA8RZ/sI=; b=rF7f3dTOJ12Q7pqeew0o6L3CZSLSGeXXKEnsR+sIcteQtmF7vCe8VYTebZV1Qe8HjR b0E6p/B3zh/9u+qdx/+sXJEcVfTW9rV+qvfL+iBx7sQMwKQBjYJWLfWxFtglt81RVJHK UpCFrflwC5lj8NpFQKRyNyS65BQ0TDjEAhdXBzQJzBL6nr1Lz9bRGS/8i9lug5KVpYUg Vbw8C3QSIZ3Teq7dRFWaLBLdaJ2isaZFCRTNdLTtFm+X5FdoJrt0ZD6Sgk8UF3gTyy7Q v3Hpuggf34+vV8GUwZ+Bo+mpHerCZZ+nTxFW9QivU+UtBTxXNnjjZGnggc4sEeB8cGS2 5SDA== X-Gm-Message-State: AFeK/H24QOuB9C+QMu8uKhyAzemQ8U9AxjQB2QkhsgIwbJHeJCNyrg0FUX27aXuOYGBlcg== X-Received: by 10.28.105.8 with SMTP id e8mr15399859wmc.122.1490715608847; Tue, 28 Mar 2017 08:40:08 -0700 (PDT) Received: from E107787-LIN ([194.214.185.158]) by smtp.gmail.com with ESMTPSA id k190sm4113782wmg.10.2017.03.28.08.40.07 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 28 Mar 2017 08:40:08 -0700 (PDT) From: Yao Qi To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 1/2] Add constructor and destructor to thread_info References: <1490689483-16084-1-git-send-email-yao.qi@linaro.org> <1490689483-16084-2-git-send-email-yao.qi@linaro.org> <06385391-127e-87b7-d727-7d03a23f293c@redhat.com> <86inmto5nx.fsf@gmail.com> Date: Tue, 28 Mar 2017 15:40:00 -0000 In-Reply-To: (Pedro Alves's message of "Tue, 28 Mar 2017 15:47:36 +0100") Message-ID: <86efxho1f2.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg00487.txt.bz2 Pedro Alves writes: >>> - struct target_waitstatus pending_follow; >>> + struct target_waitstatus pending_follow {TARGET_WAITKIND_SPURIOUS}; >>> >>=20 >> This will only initialize the first member of union >> target_waitstatus.value to zero, so some bits of >> target_waitstatus.value.related_pid is not initialized. > > Ah, blah, unions. Well, the result is that the remaining fields of > the struct end up list->value->zero-initialized. Zero-initialization > for unions means the first member is zero-initialized, and padding > is initialized to zero. So I think the end result is the > same anyway. It is different from "memset (&this->pending_follow, 0, sizeof (this->pending_follow))". The first member "integer" is zero-initialized, but it is not the largest member, so part of "related_pid" is not zero-initialized. |<------------------ union----------------->| |<------- related_pid ------->|<- padding ->| |<- integer ->| | 0 || 0 | --=20 Yao (=E9=BD=90=E5=B0=A7)