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

             Bug #: 51253
           Summary: [C++11][DR 1030] Evaluation order (sequenced-before
                    relation) among intializer-clauses in braced-init-list
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: ai.az...@gmail.com


Since DR 1030 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1030
was accepted, I expect that the following code is well-defined and exits with
the status code 0. However, GCC 4.7.0 20111112 (experimental) with -std=c++11
produces a wrong executable. In addition, it spuriously warns about undefined
operations with -Wsequence-point option.

//////////////////////////////////
struct swallow{
  template<typename... Types>
  swallow(Types &&...){}
};

template<int... IS>
int f()
{
  int i = 2;
  swallow{ i = i * IS + IS... };
  return i;
}

int main()
{
  // `i = i * 2 + 2' should be sequenced before `i = i * 3 + 3'
  return f<2, 3>() == 21 ? 0 : 1;
}
//////////////////////////////////

Reply via email to