public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/58738] forward declaration of function inside function cause link problem with optimization
Date: Tue, 15 Oct 2013 13:09:00 -0000	[thread overview]
Message-ID: <bug-58738-4-WzzwsrEYUR@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-58738-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58738

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The standard says:

The name of a function declared in block scope and the name of a variable
declared by a block scope extern declaration have linkage. If there is a
visible declaration of an entity with linkage having the same name and type,
ignoring entities declared outside the innermost enclosing namespace scope, the
block scope declaration declares that same entity and receives the linkage of
the previous declaration. If there is more than one such matching entity, the
program is ill-formed. Otherwise, if no matching entity is found, the block
scope entity
receives external linkage.

That means the first declaration of bar() has external linkage, but the later
definition has internal linkage because it's a member of an unnamed namespace,
so the declaration does not match the definition.

So I think your program is invalid.


  reply	other threads:[~2013-10-15 13:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-15 12:38 [Bug c++/58738] New: " dushistov at mail dot ru
2013-10-15 13:09 ` redi at gcc dot gnu.org [this message]
2013-10-15 14:07 ` [Bug c++/58738] " dushistov at mail dot ru
2021-09-10  0:00 ` pinskia at gcc dot gnu.org
2021-09-10  0:04 ` pinskia at gcc dot gnu.org

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=bug-58738-4-WzzwsrEYUR@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).