From owner-freebsd-hackers@FreeBSD.ORG Sun Nov 18 13:37:13 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 80F2D6C1; Sun, 18 Nov 2012 13:37:13 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (cl-327.ede-01.nl.sixxs.net [IPv6:2001:7b8:2ff:146::2]) by mx1.freebsd.org (Postfix) with ESMTP id 3A11B8FC0C; Sun, 18 Nov 2012 13:37:13 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7:0:2033:bac8:a848:cb45] (unknown [IPv6:2001:7b8:3a7:0:2033:bac8:a848:cb45]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 73E235C37; Sun, 18 Nov 2012 14:37:11 +0100 (CET) Message-ID: <50A8E487.1020105@FreeBSD.org> Date: Sun, 18 Nov 2012 14:37:11 +0100 From: Dimitry Andric Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Navdeep Parhar Subject: Re: clang mangling some static struct names? References: <50A6A3BD.5000901@gmail.com> <20121116214919.GA41725@freebsd.org> <50A6B85F.6090707@gmail.com> In-Reply-To: <50A6B85F.6090707@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org, Roman Divacky X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Nov 2012 13:37:13 -0000 On 2012-11-16 23:04, Navdeep Parhar wrote: > On 11/16/12 13:49, Roman Divacky wrote: >> Yes, it does that. iirc so that you can have things like >> >> void foo(int cond) { >> if (cond) { >> static int i = 7; >> } else { >> static int i = 8; >> } >> } >> >> working correctly. > > It's not appending the .n everywhere. And when it does, I don't see any > potential collision that it prevented by doing so. Instead, it looks > like the .n symbol corresponds to the nth element in the structure (so > this is not name mangling in the true sense). I just don't see the > point in doing things this way. It is only making things harder for > debuggers. I don't think the point is making things harder for debuggers, the point is optimization. Since static variables and functions can be optimized away, or arbitrarily moved around, you cannot count on those symbols being there at all.