Possible bug in gcc handling of std::unique_ptr<void>

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I asked this question on Stack Overflow (http://stackoverflow.com/questions/19840937/should-stdunique-ptrvoid-be-permitted).  The question, "Should std::unqiue_ptr<void> be permitted?"  As is referenced in the SO article, consider this code:

#include <iostream>
#include <memory>

typedef std::unique_ptr<void> UniqueVoidPtr;

int main() {
    UniqueVoidPtr p(new int);
    return 0;
}

I am using cygwin G++ 4.5.3 for comparison.  Using this compilation command, I receive no issues (complaints) from the compiler and the program runs without issue:

g++ -Wall -std=c++0x -o <output> file.cpp

Compiling the exact same file using Visual Studio 2010 and 2013 produces this:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\memory(2067) : error C2070: 'void': illegal sizeof operand
        C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\memory(2066) : while compiling class template member function 'void std::default_delete<_Ty>::operator ()(_Ty *) const'
        with
        [
            _Ty=void
        ]
        C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\type_traits(650) : see reference to class template instantiation 'std::default_delete<_Ty>' being compiled
        with
        [
            _Ty=void
        ]
        C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\memory(2193) : see reference to class template instantiation 'std::tr1::is_empty<_Ty>' being compiled
        with
        [
            _Ty=std::default_delete<void>
        ]
        foo1.cpp(7) : see reference to class template instantiation 'std::unique_ptr<_Ty>' being compiled
        with
        [
            _Ty=void
        ]


If you jump to the SO article, you'll see I was promptly told that "Microsoft Compiler is right; GCC is wrong."  From my own review of the C++ draft I have, it would seem that this rather curt observation is correct.  I wanted to ask here for completeness.  If this is a bug in GCC, how do I submit a bug?  Is this fixed in later releases?  (Incidentally, the only other GCC I have is the gcc on CentOS 6.2 box which is 4.4.4.)

Andy





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux