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 libstdc++/58403] __normal_iterator triggers odr-use
Date: Thu, 12 Sep 2013 14:31:00 -0000	[thread overview]
Message-ID: <bug-58403-4-vJel6XJQ7s@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-58403-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
http://gcc.gnu.org/wiki/VerboseDiagnostics#missing_static_const_definition

You odr-use a static member variable, so it must have a definition.  The linker
error is your fault for not defining the static member, not the library's fault
for using a reference parameter.

If you add the missing definition the program links:

constexpr std::iterator_traits<std::string::iterator>::difference_type A::a;

So I have no objection to changing __normal_iterator to take the parameter by
value, but taking it by reference is not a bug.  It is unspecified whether
"it += A::a" is an odr-use or not.

Your program will also fail to link if you do this:

    std::max(A::a, A::a);

But clearly we're not going to change std::max, that would be non-conforming.


  parent reply	other threads:[~2013-09-12 14:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-12 10:30 [Bug libstdc++/58403] New: " lichray at gmail dot com
2013-09-12 10:48 ` [Bug libstdc++/58403] " paolo.carlini at oracle dot com
2013-09-12 10:53 ` lichray at gmail dot com
2013-09-12 11:04 ` paolo.carlini at oracle dot com
2013-09-12 11:43 ` redi at gcc dot gnu.org
2013-09-12 13:00 ` lichray at gmail dot com
2013-09-12 13:44 ` paolo.carlini at oracle dot com
2013-09-12 14:31 ` redi at gcc dot gnu.org [this message]
2013-09-12 14:38 ` paolo.carlini at oracle dot com
2013-09-12 14:59 ` lichray at gmail dot com
2013-09-12 15:04 ` redi at gcc dot gnu.org
2013-09-12 15:15 ` paolo at gcc dot gnu.org
2013-09-12 15:17 ` paolo.carlini at oracle dot com

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-58403-4-vJel6XJQ7s@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).