[Bug libstdc++/55320] New: Invalid delete with throwing copy-c'tor passed to std::function

2012-11-13 Thread benjamin.kircher at gmail dot com


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



 Bug #: 55320

   Summary: Invalid delete with throwing copy-c'tor passed to

std::function

Classification: Unclassified

   Product: gcc

   Version: 4.7.2

Status: UNCONFIRMED

  Severity: normal

  Priority: P3

 Component: libstdc++

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

ReportedBy: benjamin.kirc...@gmail.com





Created attachment 28682

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28682

Example program



The example program attached compiles w/o warnings and crashes with an invalid

delete when executed.





$ gcc --version

gcc (Debian 4.7.2-4) 4.7.2





$ cat main.cpp

#include 

#include 

#include 

#include 



struct functor

{

functor() = default;

functor(const functor&) { throw std::exception(); }

void operator()() {}

};



int main()

try

{

std::function func = functor();

return 0;

}

catch (std::exception&)

{

std::cout << "catched" << std::endl;

}





Valgrind gives me

$ valgrind --tool=memcheck ./a.out



==...== Invalid free() / delete / delete[] / realloc()

==...==at 0x...: operator delete(void*) (in

/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)

==...==by 0x...:

std::_Function_base::_Base_manager::_M_destroy(std::_Any_data&,

std::integral_constant) (functional:1780)

==...==by 0x...:

std::_Function_base::_Base_manager::_M_manager(std::_Any_data&,

std::_Any_data const&, std::_Manager_operation) (functional:1804)

==...==by 0x...: std::_Function_base::~_Function_base() (functional:1885)

==...==by 0x...: std::function::function(functor,

std::enable_if::value), std::function::_Useless>::type) (functional:2292)





On clang/libc++ this behaves as expected.


[Bug libstdc++/55320] Invalid delete with throwing copy-c'tor passed to std::function

2012-11-14 Thread benjamin.kircher at gmail dot com


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



--- Comment #1 from Benjamin Kircher  
2012-11-14 08:10:06 UTC ---

Sorry.



System type was

$ uname -a

Linux  3.2.0-4-486 #1 Debian 3.2.32-1 i686 GNU/Linux

$ file a.out 

a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically

linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=, not

stripped





Command line that produced the error was

$ g++ -g -std=c++11 -Wall -Wextra -pedantic main.cpp


[Bug libstdc++/55409] New: std::list not properly wrapping access to custom allocator through allocator_traits

2012-11-20 Thread benjamin.kircher at gmail dot com

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

 Bug #: 55409
   Summary: std::list not properly wrapping access to custom
allocator through allocator_traits
Classification: Unclassified
   Product: gcc
   Version: 4.7.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: benjamin.kirc...@gmail.com


Created attachment 28741
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28741
Small example showing simple custom allocator with std::list and std::vector

The attached source file compiles fine with a std::vector as container_type.
Using std::list however, compilation fails with the error message given below.
Expected behavior is that it compiles with std::list as like with std::vector.

$ gcc --version
gcc (Debian 4.7.2-4) 4.7.2


$ cat main.cpp
template class my_alloc
{
// class template supporting the minimal interface according to 17.6.3.5
};

int main()
{
//typedef std::vector> container_type;
typedef std::list> container_type;
container_type cont;
cont.push_back(11);
cont.push_back(22);
cont.push_back(33);
return 0;
}


$ g++ -g -std=c++11 -Wall -Wextra -pedantic main.cpp

/usr/include/c++/4.7/bits/stl_list.h: In instantiation of ‘class std::list >’:
main.cpp:56:20:   required from here
/usr/include/c++/4.7/bits/stl_list.h:449:58: error: no type named ‘pointer’ in
‘std::list >::_Tp_alloc_type {aka class my_alloc}’
/usr/include/c++/4.7/bits/stl_list.h:450:58: error: no type named
‘const_pointer’ in ‘std::list >::_Tp_alloc_type {aka class
my_alloc}’
/usr/include/c++/4.7/bits/stl_list.h:451:58: error: no type named ‘reference’
in ‘std::list >::_Tp_alloc_type {aka class my_alloc}’
/usr/include/c++/4.7/bits/stl_list.h:452:58: error: no type named
‘const_reference’ in ‘std::list >::_Tp_alloc_type {aka class
my_alloc}’

and so on.


[Bug libstdc++/55409] std::list not properly wrapping access to custom allocator through allocator_traits

2012-11-20 Thread benjamin.kircher at gmail dot com


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



--- Comment #3 from Benjamin Kircher  
2012-11-20 09:31:07 UTC ---

Thank you for working on it and for the remark.



NB: For the next time, where can I find the documentation?