public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Georg-Johann Lay <avr@gjlay.de>
Cc: Jay K <jayk123@hotmail.com>, gcc <gcc@gcc.gnu.org>
Subject: Re: extern const initialized warns in C
Date: Thu, 25 Jan 2018 12:29:00 -0000	[thread overview]
Message-ID: <CAH6eHdSNEP-ON6YAZd6ag8CiK__83xiEAWXqLqQb7ipEU5+qJg@mail.gmail.com> (raw)
In-Reply-To: <1022626e-60a8-c510-c687-4c6e385bd5e0@gjlay.de>

On 25 January 2018 at 12:27, Georg-Johann Lay wrote:
> On 22.01.2018 16:20, Jonathan Wakely wrote:
>>
>> On 21 January 2018 at 12:08, Georg-Johann Lay wrote:
>>>
>>> Jay K schrieb:
>>>>
>>>>
>>>> extern const int foo = 123;
>>>>
>>>> Why does this warn?
>>>> This is a valid portable form, with the same meaning
>>>> across all compilers, and, importantly, portably
>>>> to C and C++.
>>>
>>>
>>> I also wondered about this.
>>>
>>> In C99 §6.9.2 "External object definitions" there's actually
>>> the following example in clause 4:
>>>
>>> extern int i3 = 3; // definition, external linkage
>>
>>
>> That's a different case. There's no advantage to the 'extern' here,
>> because the code means the same thing in C and C++ without the
>> 'extern', so just leave it out.
>
>
> I'd rather like to know why GCC is throwing a warning here.
>
> It's clear how to hack the C source, but that's a different point.
>
> It's just the case that I don't see any problem with that construct,
> and it was worth an explicit example in the standard.  Or is it
> common practice to warn constructs that are "no advantage"?

Read https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45977 (as already
stated earlier in the thread).

  reply	other threads:[~2018-01-25 12:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <MWHPR18MB121493D9F2292547E0AF6C3AE6ED0@MWHPR18MB1214.namprd18.prod.outlook.com>
2018-01-21  7:12 ` Jay K
2018-01-21 12:08   ` Georg-Johann Lay
2018-01-22  9:44     ` Franz Sirl
2018-01-22 15:20     ` Jonathan Wakely
2018-01-25 12:27       ` Georg-Johann Lay
2018-01-25 12:29         ` Jonathan Wakely [this message]
2018-01-25 12:30           ` Jonathan Wakely
2018-01-22  8:32   ` David Brown
2018-01-22  9:32     ` Jay K
2018-01-22  9:39       ` Jay K
2018-01-22 10:14         ` David Brown
2018-01-22 10:25           ` Jay K
2018-01-22  9:54       ` David Brown
     [not found]         ` <MWHPR18MB12145B5B3E0B093993C2D214E6EC0@MWHPR18MB1214.namprd18.prod.outlook.com>
2018-01-22 10:42           ` David Brown
2018-01-22 11:27             ` Jay K
2018-01-22 13:02               ` David Brown
2018-01-22 16:22         ` Vincent Lefevre
2018-01-22 15:19   ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH6eHdSNEP-ON6YAZd6ag8CiK__83xiEAWXqLqQb7ipEU5+qJg@mail.gmail.com \
    --to=jwakely.gcc@gmail.com \
    --cc=avr@gjlay.de \
    --cc=gcc@gcc.gnu.org \
    --cc=jayk123@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).