public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58829] New: non-static member initializer in nested template class produces incorrect compile error
@ 2013-10-21 22:04 lhyatt at gmail dot com
  2013-10-21 22:35 ` [Bug c++/58829] " paolo.carlini at oracle dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: lhyatt at gmail dot com @ 2013-10-21 22:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58829
           Summary: non-static member initializer in nested template class
                    produces incorrect compile error
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lhyatt at gmail dot com

==========
struct A {
    int f() {return 0;}
} a;

struct B {
    template<int=0> struct C {
        int i = a.f();
    };
};
B::C<> c;
============

Above snippet is valid C++11, fails to compile with the following error:

t.cpp: In constructor 'constexpr B::C<>::C()':
t.cpp:7:21: error: no matching function for call to 'A::f(A*)'
         int i = a.f();
                     ^
t.cpp:7:21: note: candidate is:
t.cpp:2:9: note: int A::f()
     int f() {return 0;}
         ^
t.cpp:2:9: note:   candidate expects 0 arguments, 1 provided
t.cpp: At global scope:
t.cpp:10:8: note: synthesized method 'constexpr B::C<>::C()' first required
here
 B::C<> c;

If you make C a non-template, or remove the outer class B in which C is nested,
then it works OK. clang compiles it OK. I see it on 4.8.1 and on the current
svn mainline.

$ g++ -v -std=c++11 -o t.o -c t.cpp
Using built-in specs.
COLLECT_GCC=/usr/local/gcc48/bin/g++
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --enable-threads=posix --enable-__cxa_atexit
--prefix=/usr/local/gcc-4.8.1
Thread model: posix
gcc version 4.8.1 (GCC)
COLLECT_GCC_OPTIONS='-v' '-std=c++11' '-o' 't.o' '-c' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
 /usr/local/gcc-4.8.1/libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/cc1plus -quiet
-v -D_GNU_SOURCE t.cpp -quiet -dumpbase t.cpp -mtune=generic -march=x86-64
-auxbase-strip t.o -std=c++11 -version -o /tmp/ccxl7AbU.s
GNU C++ (GCC) version 4.8.1 (x86_64-unknown-linux-gnu)
    compiled by GNU C version 4.8.1, GMP version 4.3.2, MPFR version 2.4.2-p1,
MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory
"/usr/local/gcc-4.8.1/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:

/usr/local/gcc-4.8.1/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../include/c++/4.8.1

/usr/local/gcc-4.8.1/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../include/c++/4.8.1/x86_64-unknown-linux-gnu

/usr/local/gcc-4.8.1/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../include/c++/4.8.1/backward
 /usr/local/gcc-4.8.1/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/include
 /usr/local/include
 /usr/local/gcc-4.8.1/include
 /usr/local/gcc-4.8.1/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/include-fixed
 /usr/include
End of search list.
GNU C++ (GCC) version 4.8.1 (x86_64-unknown-linux-gnu)
    compiled by GNU C version 4.8.1, GMP version 4.3.2, MPFR version 2.4.2-p1,
MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 9381368e685e312c931bb6a2db2d568c
t.cpp: In constructor 'constexpr B::C<>::C()':
t.cpp:7:21: error: no matching function for call to 'A::f(A*)'
         int i = a.f();
                     ^
t.cpp:7:21: note: candidate is:
t.cpp:2:9: note: int A::f()
     int f() {return 0;}
         ^
t.cpp:2:9: note:   candidate expects 0 arguments, 1 provided
t.cpp: At global scope:
t.cpp:10:8: note: synthesized method 'constexpr B::C<>::C()' first required
here
 B::C<> c;
        ^


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

* [Bug c++/58829] non-static member initializer in nested template class produces incorrect compile error
  2013-10-21 22:04 [Bug c++/58829] New: non-static member initializer in nested template class produces incorrect compile error lhyatt at gmail dot com
@ 2013-10-21 22:35 ` paolo.carlini at oracle dot com
  2013-11-15 23:21 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-21 22:35 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-10-21
             Blocks|                            |58616
     Ever confirmed|0                           |1


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

* [Bug c++/58829] non-static member initializer in nested template class produces incorrect compile error
  2013-10-21 22:04 [Bug c++/58829] New: non-static member initializer in nested template class produces incorrect compile error lhyatt at gmail dot com
  2013-10-21 22:35 ` [Bug c++/58829] " paolo.carlini at oracle dot com
@ 2013-11-15 23:21 ` paolo.carlini at oracle dot com
  2013-11-15 23:52 ` paolo at gcc dot gnu.org
  2013-11-15 23:55 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-11-15 23:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
This is also fixed in mainline. I'm adding the testcase and closing the bug.


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

* [Bug c++/58829] non-static member initializer in nested template class produces incorrect compile error
  2013-10-21 22:04 [Bug c++/58829] New: non-static member initializer in nested template class produces incorrect compile error lhyatt at gmail dot com
  2013-10-21 22:35 ` [Bug c++/58829] " paolo.carlini at oracle dot com
  2013-11-15 23:21 ` paolo.carlini at oracle dot com
@ 2013-11-15 23:52 ` paolo at gcc dot gnu.org
  2013-11-15 23:55 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo at gcc dot gnu.org @ 2013-11-15 23:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Fri Nov 15 23:51:23 2013
New Revision: 204881

URL: http://gcc.gnu.org/viewcvs?rev=204881&root=gcc&view=rev
Log:
2013-11-15  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/58188
    * g++.dg/cpp0x/nsdmi-template8.C: New.

2013-11-15  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/58725
    * g++.dg/cpp0x/nsdmi-template7.C: New.

2013-11-15  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/58829
    * g++.dg/cpp0x/nsdmi-template6.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/nsdmi-template6.C
    trunk/gcc/testsuite/g++.dg/cpp0x/nsdmi-template7.C
    trunk/gcc/testsuite/g++.dg/cpp0x/nsdmi-template8.C
Modified:
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/58829] non-static member initializer in nested template class produces incorrect compile error
  2013-10-21 22:04 [Bug c++/58829] New: non-static member initializer in nested template class produces incorrect compile error lhyatt at gmail dot com
                   ` (2 preceding siblings ...)
  2013-11-15 23:52 ` paolo at gcc dot gnu.org
@ 2013-11-15 23:55 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-11-15 23:55 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |4.9.0

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Done.


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

end of thread, other threads:[~2013-11-15 23:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-21 22:04 [Bug c++/58829] New: non-static member initializer in nested template class produces incorrect compile error lhyatt at gmail dot com
2013-10-21 22:35 ` [Bug c++/58829] " paolo.carlini at oracle dot com
2013-11-15 23:21 ` paolo.carlini at oracle dot com
2013-11-15 23:52 ` paolo at gcc dot gnu.org
2013-11-15 23:55 ` paolo.carlini at oracle dot com

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