public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51048] New: Class template inheritance doesn't work well with function-local types
@ 2011-11-09  6:42 Fetrovsky at gmail dot com
  2011-11-09 12:38 ` [Bug c++/51048] " daniel.kruegler at googlemail dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Fetrovsky at gmail dot com @ 2011-11-09  6:42 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51048
           Summary: Class template inheritance doesn't work well with
                    function-local types
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: Fetrovsky@gmail.com


#include <vector>

template<typename X>
struct A { 
     X x;

     virtual X const& Push(X const& x) = 0;

     template<typename Y>
     X const& Push(Y const& y) {
          for (std::size_t i = 0; i < y.size(); ++i)
               Push(y[i]);
     }   
};

template<typename X>
struct B: A<X> {
     using A<X>::Push;
     virtual X const& Push(X const& x) { return A<X>::x = x; }
};

int F() {
     enum S { x, y };
     return B<S>().Push(std::vector<S>(3, x));
}

int main() {
     return F();
}


I get the following:
prog.cpp:7:23: error: 'const X& A<X>::Push(const X&) [with X = F()::S]',
declared using local type 'const F()::S', is used but never defined

If I take S out of F() and define it in the global namespace, it works fine.


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

* [Bug c++/51048] Class template inheritance doesn't work well with function-local types
  2011-11-09  6:42 [Bug c++/51048] New: Class template inheritance doesn't work well with function-local types Fetrovsky at gmail dot com
@ 2011-11-09 12:38 ` daniel.kruegler at googlemail dot com
  2013-07-30 22:55 ` paolo.carlini at oracle dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-11-09 12:38 UTC (permalink / raw)
  To: gcc-bugs

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

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler at
                   |                            |googlemail dot com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2011-11-09 12:23:54 UTC ---
Simplifying the test case and compiled with

-std=c++0x -Wall

//---
template<typename X>
struct A {
  virtual void DoPush(X const& x) = 0; // Line 3
  void Push(X const& x) { DoPush(x); }
};

template<typename X>
struct B : A<X> {
  using A<X>::Push;
  virtual void DoPush(X const&) { }
};

int main() {
  enum S { };
  B<S>().Push(S());
}
//---

"main.cpp|3|error: 'void A<X>::DoPush(const X&) [with X = main()::S]', declared
using local type 'const main()::S', is used but never defined [-fpermissive]|"

It is important that the virtual function is pure. Validated for gcc  4.7.0
20111105 (experimental).


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

* [Bug c++/51048] Class template inheritance doesn't work well with function-local types
  2011-11-09  6:42 [Bug c++/51048] New: Class template inheritance doesn't work well with function-local types Fetrovsky at gmail dot com
  2011-11-09 12:38 ` [Bug c++/51048] " daniel.kruegler at googlemail dot com
@ 2013-07-30 22:55 ` paolo.carlini at oracle dot com
  2013-09-28 15:08 ` cameron314 at gmail dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-07-30 22:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppluzhnikov at google dot com

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> ---
*** Bug 58032 has been marked as a duplicate of this bug. ***


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

* [Bug c++/51048] Class template inheritance doesn't work well with function-local types
  2011-11-09  6:42 [Bug c++/51048] New: Class template inheritance doesn't work well with function-local types Fetrovsky at gmail dot com
  2011-11-09 12:38 ` [Bug c++/51048] " daniel.kruegler at googlemail dot com
  2013-07-30 22:55 ` paolo.carlini at oracle dot com
@ 2013-09-28 15:08 ` cameron314 at gmail dot com
  2013-09-28 15:10 ` cameron314 at gmail dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cameron314 at gmail dot com @ 2013-09-28 15:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Cameron <cameron314 at gmail dot com> ---
Created attachment 30923
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30923&action=edit
Self contained test case to reproduce bug 51048


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

* [Bug c++/51048] Class template inheritance doesn't work well with function-local types
  2011-11-09  6:42 [Bug c++/51048] New: Class template inheritance doesn't work well with function-local types Fetrovsky at gmail dot com
                   ` (2 preceding siblings ...)
  2013-09-28 15:08 ` cameron314 at gmail dot com
@ 2013-09-28 15:10 ` cameron314 at gmail dot com
  2015-06-15 11:16 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cameron314 at gmail dot com @ 2013-09-28 15:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Cameron <cameron314 at gmail dot com> ---
Comment on attachment 30923
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30923
Self contained test case to reproduce bug 51048

Tested with g++ 4.8.1. g++ -v yields:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.1/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-linker-build-id --with-linker-hash-style=gnu
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin
--enable-initfini-array --enable-java-awt=gtk --disable-dssi
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-isl=/builddir/build/BUILD/gcc-4.8.1-20130603/obj-x86_64-redhat-linux/isl-install
--with-cloog=/builddir/build/BUILD/gcc-4.8.1-20130603/obj-x86_64-redhat-linux/cloog-install
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.1 20130603 (Red Hat 4.8.1-1) (GCC)


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

* [Bug c++/51048] Class template inheritance doesn't work well with function-local types
  2011-11-09  6:42 [Bug c++/51048] New: Class template inheritance doesn't work well with function-local types Fetrovsky at gmail dot com
                   ` (3 preceding siblings ...)
  2013-09-28 15:10 ` cameron314 at gmail dot com
@ 2015-06-15 11:16 ` paolo.carlini at oracle dot com
  2015-06-15 12:01 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-06-15 11:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2015-06-15
           Assignee|unassigned at gcc dot gnu.org      |paolo.carlini at oracle dot com
     Ever confirmed|0                           |1

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Mine.


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

* [Bug c++/51048] Class template inheritance doesn't work well with function-local types
  2011-11-09  6:42 [Bug c++/51048] New: Class template inheritance doesn't work well with function-local types Fetrovsky at gmail dot com
                   ` (4 preceding siblings ...)
  2015-06-15 11:16 ` paolo.carlini at oracle dot com
@ 2015-06-15 12:01 ` paolo.carlini at oracle dot com
  2015-06-15 19:27 ` paolo at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-06-15 12:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> ---
*** Bug 59975 has been marked as a duplicate of this bug. ***


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

* [Bug c++/51048] Class template inheritance doesn't work well with function-local types
  2011-11-09  6:42 [Bug c++/51048] New: Class template inheritance doesn't work well with function-local types Fetrovsky at gmail dot com
                   ` (5 preceding siblings ...)
  2015-06-15 12:01 ` paolo.carlini at oracle dot com
@ 2015-06-15 19:27 ` paolo at gcc dot gnu.org
  2015-10-12 13:16 ` paolo at gcc dot gnu.org
  2015-10-12 13:17 ` paolo.carlini at oracle dot com
  8 siblings, 0 replies; 10+ messages in thread
From: paolo at gcc dot gnu.org @ 2015-06-15 19:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Mon Jun 15 19:26:27 2015
New Revision: 224492

URL: https://gcc.gnu.org/viewcvs?rev=224492&root=gcc&view=rev
Log:
/cp
2015-06-15  Paolo Carlini  <paolo.carlini@oracle.com>

        PR c++/51048
        * decl2.c (no_linkage_error): Do not issue a permerror if the DECL
        using a local type is pure virtual.

/testsuite
2015-06-15  Paolo Carlini  <paolo.carlini@oracle.com>

        PR c++/51048
        * g++.dg/cpp0x/local-type1.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/local-type1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl2.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/51048] Class template inheritance doesn't work well with function-local types
  2011-11-09  6:42 [Bug c++/51048] New: Class template inheritance doesn't work well with function-local types Fetrovsky at gmail dot com
                   ` (6 preceding siblings ...)
  2015-06-15 19:27 ` paolo at gcc dot gnu.org
@ 2015-10-12 13:16 ` paolo at gcc dot gnu.org
  2015-10-12 13:17 ` paolo.carlini at oracle dot com
  8 siblings, 0 replies; 10+ messages in thread
From: paolo at gcc dot gnu.org @ 2015-10-12 13:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Mon Oct 12 13:15:30 2015
New Revision: 228714

URL: https://gcc.gnu.org/viewcvs?rev=228714&root=gcc&view=rev
Log:
/cp
2015-10-12  Paolo Carlini  <paolo.carlini@oracle.com>

        Backport from mainline
        2015-06-15  Paolo Carlini  <paolo.carlini@oracle.com>

        PR c++/51048
        * decl2.c (no_linkage_error): Do not issue a permerror if the DECL
        using a local type is pure virtual.

/testsuite
2015-10-12  Paolo Carlini  <paolo.carlini@oracle.com>

        Backport from mainline
        2015-06-15  Paolo Carlini  <paolo.carlini@oracle.com>

        PR c++/51048
        * g++.dg/cpp0x/local-type1.C: New.

Added:
    branches/gcc-5-branch/gcc/testsuite/g++.dg/cpp0x/local-type1.C
Modified:
    branches/gcc-5-branch/gcc/cp/ChangeLog
    branches/gcc-5-branch/gcc/cp/decl2.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog


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

* [Bug c++/51048] Class template inheritance doesn't work well with function-local types
  2011-11-09  6:42 [Bug c++/51048] New: Class template inheritance doesn't work well with function-local types Fetrovsky at gmail dot com
                   ` (7 preceding siblings ...)
  2015-10-12 13:16 ` paolo at gcc dot gnu.org
@ 2015-10-12 13:17 ` paolo.carlini at oracle dot com
  8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-10-12 13:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rodrigc at gcc dot gnu.org

--- Comment #10 from Paolo Carlini <paolo.carlini at oracle dot com> ---
*** Bug 67888 has been marked as a duplicate of this bug. ***


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

end of thread, other threads:[~2015-10-12 13:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-09  6:42 [Bug c++/51048] New: Class template inheritance doesn't work well with function-local types Fetrovsky at gmail dot com
2011-11-09 12:38 ` [Bug c++/51048] " daniel.kruegler at googlemail dot com
2013-07-30 22:55 ` paolo.carlini at oracle dot com
2013-09-28 15:08 ` cameron314 at gmail dot com
2013-09-28 15:10 ` cameron314 at gmail dot com
2015-06-15 11:16 ` paolo.carlini at oracle dot com
2015-06-15 12:01 ` paolo.carlini at oracle dot com
2015-06-15 19:27 ` paolo at gcc dot gnu.org
2015-10-12 13:16 ` paolo at gcc dot gnu.org
2015-10-12 13:17 ` 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).