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



             Bug #: 56697

           Summary: Erroneous rejection of use of private constructor in

                    public method

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: n...@cam.ac.uk





What I believe is an erroneous rejection of a program.  Unfortunately, the

C++ standard is too contorted in this area for me to be absolutely sure,

Anyway, Intel is happy with it.



wheeler$cat junk.cpp

class weeble {

public:

    weeble () {}

    class wurble {

        int n;

        wurble (int k) : n(k) {}

    public:

        wurble () : n(0) {}

    };

    wurble fred (int k) {return wurble(k);}

};



int main () {

    weeble a;

    weeble::wurble b = a.fred(42);

}





wheeler$/home/nmm/GCC/bin/g++ -v

Using built-in specs.

COLLECT_GCC=/home/nmm/GCC/bin/g++

COLLECT_LTO_WRAPPER=/home/nmm/GCC/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper

Target: x86_64-unknown-linux-gnu

Configured with: ../gcc-4.8-20130127/configure --prefix=/home/nmm/GCC

--disable-bootstrap --enable-checking=all --enable-languages=c,c++,fortran :

(reconfigured) ../gcc-4.8-20130127/configure --prefix=/home/nmm/GCC

--disable-bootstrap --enable-languages=c,c++,fortran

Thread model: posix

gcc version 4.8.0 20130127 (experimental) (GCC) 





wheeler$/home/nmm/GCC/bin/g++ junk.cpp

junk.cpp: In member function 'weeble::wurble weeble::fred(int)':

junk.cpp:6:9: error: 'weeble::wurble::wurble(int)' is private

         wurble (int k) : n(k) {}

         ^

junk.cpp:10:41: error: within this context

     wurble fred (int k) {return wurble(k);}

                                         ^

Reply via email to