This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/59659] New: large zero-initialized std::array of std::atomic compile time excessive


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

            Bug ID: 59659
           Summary: large zero-initialized std::array of std::atomic
                    compile time excessive
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: devaneymark at gmail dot com

Compiling the below with any of the zero-initialization forms of std::atomic
takes at least several hours (3GhZ Intel).   The default-initialized and
non-atomic forms compile immediately.

g++ --std=c++11 -O0 : no other compile flags

reproducible under 4.8.2 and 4.7.2


#include <iostream>
#include <array>
#include <algorithm>
#include <atomic>

int main(int argc, char* argv[]) {

    // std::array<std::atomic<int>, 1000000>  arr;         // default
initialization (i.e., random data) = FAST

    std::array<std::atomic<int>, 1000000>  arr{{}};   // zero initialization =
FOREVER

    //std::array<std::atomic<int>, 1000000>  arr{};   // zero initialization =
FOREVER

    //std::array<std::atomic<int>, 1000000>  arr={{}};     // zero init via
assignment = FOREVER

    //std::array<int, 1000000>  arr={{}};     // zero init non-atomic = FAST

    std::cerr << "sum = " << std::accumulate(arr.begin(), arr.end(), 0) <<
std::endl;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]