public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99611] New: Code compilation issue using templates
@ 2021-03-16  6:35 asif_bahrainwala at hotmail dot com
  2021-05-20 20:13 ` [Bug c++/99611] " ppalka at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: asif_bahrainwala at hotmail dot com @ 2021-03-16  6:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99611

            Bug ID: 99611
           Summary: Code compilation issue using templates
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asif_bahrainwala at hotmail dot com
  Target Milestone: ---

Hi,
a minimalist re-pro is available at
https://stackoverflow.com/questions/66641646/c-code-compilation-usage-of-fstream-ostream

The below code compiles in Clang but not in GCC (and VS2015):

#include <iostream>
#include <fstream>
using namespace std;


struct A
{
    int z=0;

    template<typename T>
    void func(T &y)
    {
        //cout<<typeid(T).name()<<endl;
        y<<z<<endl;
    }
};


template<typename T,typename T1>
T& operator<<(T &y,T1 &y1)
{
    y1.func(y);
    return y;
}

int main()
{
    A a;
    a.z=10;
    fstream fs("a.txt",ios::out);

    fs<<a; //this doesnt compile ????  ( I do have a walk around, but curious)
    cout<<a; //this works
    return 0;
}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/99611] Code compilation issue using templates
  2021-03-16  6:35 [Bug c++/99611] New: Code compilation issue using templates asif_bahrainwala at hotmail dot com
@ 2021-05-20 20:13 ` ppalka at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-05-20 20:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99611

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Thanks for the bug report.  This looks like a dup of PR51577, which has
recently been partially fixed on trunk.

*** This bug has been marked as a duplicate of bug 51577 ***

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-20 20:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16  6:35 [Bug c++/99611] New: Code compilation issue using templates asif_bahrainwala at hotmail dot com
2021-05-20 20:13 ` [Bug c++/99611] " ppalka at gcc dot gnu.org

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).