public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Klaus Lindemann <kglindemann@yahoo.de>
To: "gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>
Subject: Question related to changes in template handling
Date: Sun, 22 May 2022 17:23:11 +0000 (UTC)	[thread overview]
Message-ID: <786553971.2049625.1653240191948@mail.yahoo.com> (raw)
In-Reply-To: <786553971.2049625.1653240191948.ref@mail.yahoo.com>

Hello,
was the handling of templates changed for g++12? I've run across some programs
which did compile with e.g. g++8, g++11, but no longer compile with g++12.
The fix is quite easy, but I wonder if this change is a bug, or a more strict
implementation of the standard.
Here is a short example program:================================================// compiles with g++ 11, not g++ 12
#include <vector>namespace NN   // if namespace is removed (i.e. global namespace is used), problem does not occur{  class OStr {};}
template <class T> NN::OStr& operator<<(NN::OStr& lhs, const std::vector<T>& rhs) { return lhs << rhs[0]; }
// moving this definition before the other template definition fixes gcc 12 compile problemtemplate <class T> NN::OStr& operator<< (NN::OStr& lhs, const T& rhs) { return lhs << rhs; }
int main(){   std::vector<int> a;   NN::OStr os;   os << a;   return 0;}=================================================
Regards
Klaus

       reply	other threads:[~2022-05-22 17:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <786553971.2049625.1653240191948.ref@mail.yahoo.com>
2022-05-22 17:23 ` Klaus Lindemann [this message]
2022-05-22 18:23   ` Jonathan Wakely
2022-05-22 22:40     ` Klaus Lindemann

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=786553971.2049625.1653240191948@mail.yahoo.com \
    --to=kglindemann@yahoo.de \
    --cc=gcc-help@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).