public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/62036] New: Braced-init-list issuing -Wsequence-point warning
@ 2014-08-06 14:08 dacamara.cameron at gmail dot com
  2014-08-06 15:06 ` [Bug c++/62036] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dacamara.cameron at gmail dot com @ 2014-08-06 14:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62036

            Bug ID: 62036
           Summary: Braced-init-list issuing -Wsequence-point warning
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dacamara.cameron at gmail dot com

#include <algorithm>
#include <iostream>
#include <iterator>
#include <thread>

int main() {
    int arr[10];
    std::iota(std::begin(arr), std::end(arr), 1);
    using itr_t = decltype(std::begin(arr));

    // the function that will display each element
    auto f = [] (itr_t first, itr_t last) {while (first != last)
std::cout<<*(first++)<<' ';};

    // we have 3 threads so we need to figure out the ranges for each thread to
show
    int increment = std::distance(std::begin(arr), std::end(arr)) / 3;
    auto first    = std::begin(arr);
    auto to       = first + increment;
    auto last     = std::end(arr);
    std::thread threads[3] = {
        std::thread{f, first, to},
        std::thread{f, (first = to), (to += increment)},
        std::thread{f, (first = to), last} // go to last here to account for
odd array sizes
    };
    for (auto&& t : threads) t.join();
}


I'm getting the sequence point warning with this piece of code and when I
execute it the thread at threads[1] prints nothing whatsoever. This should be
well defined according to the standard (I'm using sec. 8.5.4.4 as reference).
The fact that gcc even issues the -Wsequence-point warning is indicative that
the standard isn't being followed.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-08-06 18:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-06 14:08 [Bug c++/62036] New: Braced-init-list issuing -Wsequence-point warning dacamara.cameron at gmail dot com
2014-08-06 15:06 ` [Bug c++/62036] " redi at gcc dot gnu.org
2014-08-06 15:12 ` dacamara.cameron at gmail dot com
2014-08-06 18:36 ` dacamara.cameron at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).