From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23362 invoked by alias); 29 Jan 2019 10:09:49 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 23354 invoked by uid 89); 29 Jan 2019 10:09:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=uhr, H*f:sk:0c95c3f, U*david, H*i:sk:0c95c3f X-HELO: mail-ua1-f44.google.com Received: from mail-ua1-f44.google.com (HELO mail-ua1-f44.google.com) (209.85.222.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 29 Jan 2019 10:09:47 +0000 Received: by mail-ua1-f44.google.com with SMTP id d2so6646489ual.2 for ; Tue, 29 Jan 2019 02:09:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8g18vR8HpT/Y+2ULO7BNuzMKIACeiasyiyKN8py/jeQ=; b=ZcmxVprjMITPkUjVFxCBlo6t9e08F7m26cYYbiLGa4O2h10s+INFWu4G+ZCGc+Tc9G NtHCeFDqUlEy6d0pl8OzzdBC9fRApml/UJYoxoSnGJhq018tED83xzsu+D+ibYUVOZJH bGBKod8yMttmsAxU0fQNxUWWJA9DqQLnvq9Wn1WrUWEX3OIa8Dbp5u+NIObP3MmStwHG +FHDVGJbqYZQvgx29oa7oaMBj/5HdKrXTlzkBIybnjI3o4t4zYhLuWjZgc1lrHPlwuoR /LA28wNBzMGsZPE2eK6zZ0jDZ47kREqvFC4lfkOPpf+Ep+fm/IRZ/SJmDOySxSNO1o2M CRQg== MIME-Version: 1.0 References: <0c95c3f5-c9cb-8e36-a1d0-9b024c666564@westcontrol.com> In-Reply-To: <0c95c3f5-c9cb-8e36-a1d0-9b024c666564@westcontrol.com> From: Bernhard Schommer Date: Tue, 29 Jan 2019 10:09:00 -0000 Message-ID: Subject: Re: -fno-common To: David Brown Cc: GCC Development Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-01/txt/msg00248.txt.bz2 Thanks for the fast answer, sorry if I posted this on the wrong list. Actually I was looking at this not due to changes in my code but rather to implement the option for another compiler and I wanted to mimic the behavior of gcc and was kind of confused in the change of behavior. Bernhard. Am Di., 29. Jan. 2019 um 10:54 Uhr schrieb David Brown : > > On 28/01/2019 16:58, Bernhard Schommer wrote: > > Hi, > > > > I would like to know if the handling of the option -fno-common has > > changed between version 7.3 and 8.2 for x86. I tried it with the > > default system version of OpenSUSE and for example: > > > > const int i; > > > > is placed in the .bss section. With a newer self-compiled version 8.2 > > the same variable is placed in the section .rodata. I could not find > > any information in the Changelog whether the behavior has changed and > > thus would like to know if there was any change. > > > > (I think this should be on gcc-help, not gcc.) > > "const int i;" is (in C) a tentative definition of an object "i" with > external linkage. If you don't give an initialiser later in the file, > it is equivalent to "const int i = 0;". The compiler knows it cannot > legally change or be anything other than 0, and can therefore put it in > the .rodata section. If you have another "const int i" definition in > another translation unit, you can expect a linker error. > > It seems that gcc 7 put this in .bss. This is equally legal for the > compiler. There should be no difference in how your code works, unless > you are breaking some other C rules along the way. > > > But there is no reason why you should ever write a line "const int i;". > A "const" definition should always have an initialiser - while this > line does the same job as "const int i = 0;" as far as the language is > concerned, it is usually considered better style to initialise const > data explicitly. > > So yes, it looks like the handling of this line has changed between > versions of the compiler. But it should not affect your code functionality. >