std::make_shared for arrays: bug in GCC or cygwin?

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

 



According to https://en.cppreference.com/w/cpp/compiler_support
GCC does not yet support "Extending std::make_shared() to support arrays"
Anyway, the following code
 
#include <memory>
#include <iostream>
template<typename T> int test()
{
    std::shared_ptr<T[]> p1 = std::make_shared<T[]>(2);
    std::shared_ptr<T[]> p2 = p1;
    p2[1] = 5;
    std::cout << p1[1] << std::endl;
    return 0;
}
int main()
{
  test<int>();
  std::cout << "Done int" << std::endl;
  test<long>();
  std::cout << "Done long" << std::endl;
}
 
compiles ad gives the expected result on Linux and when using the compiler explorer https://godbolt.org/ for GCC 10.2:

5
Done int
5
Done long
 
Using GCC 10.2 on cygwin64, however, it crashes:

5
Done int
5
Aborted (core dumped)

Maybe this is somehow related to alignment (it also crashes for double).
Is this a bug in GCC or a bug in cygwin? Or is it actually no bug because this feature is not yet supported?
 
Helmut




[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