[Bug c++/70792] New: Incorrect sequence point warning with uniform initializer syntax

2016-04-25 Thread lefticus at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70792

Bug ID: 70792
   Summary: Incorrect sequence point warning with uniform
initializer syntax
   Product: gcc
   Version: 6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: lefticus at gmail dot com
  Target Milestone: ---

The following code:


#include 

struct Do_Call
{
  template
  Do_Call(const Func &f, T && ... t)
  {
f(std::forward(t)...);
  }
};

int main()
{
  const auto sum = [](int w, int x, int y, int z) {
return w + x + y + z;
  };

  int i = 0;
  Do_Call{sum, ++i, ++i, ++i, ++i};
}

Generates the -Wsequence-point warning for the variable 'i'. However, the
standard states:

"Within the initializer-list of a braced-init-list, the initializer-clauses,
including any that result from pack expansions (14.5.3), are evaluated in the
order in which they appear. That is, every value computation and side effect
associated with a given initializer-clause is sequenced before every value
computation and side effect associated with any initializer-clause that follows
it in the comma-separated list of the initializer-list. [Note: This evaluation
ordering holds regardless of the semantics of the initialization; for example,
it applies when the elements of the initializer-list are interpreted as
arguments of a constructor call, even though ordinarily there are no sequencing
constraints on the arguments of a call. —end note ]"

The "Note: This evaluation ordering holds regardless of the semantics of the
initialization; for example, it applies when the elements of the
initializer-list are interpreted as arguments of a constructor call, even
though ordinarily there are no sequencing constraints on the arguments of a
call. —end note" is the most applicable to this bug report.

This occurs in all versions tested between 4.7.3->6

[Bug c++/70792] Incorrect sequence point warning with uniform initializer syntax

2016-04-25 Thread lefticus at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70792

--- Comment #1 from Jason Turner  ---
Note: I tested this code further and the compiler seems to be generating
incorrect code based on this standard, not just warning incorrectly.

[Bug c++/70792] Incorrect sequence point warning with uniform initializer syntax

2016-04-25 Thread lefticus at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70792

--- Comment #2 from Jason Turner  ---
Follow up, this is a better test case that does not pass by &&


struct MyType {
  MyType(int i, int j, int k, int l)
: sum(i + j + k + l)
  {

  }

  int sum;
};

int main()
{
  int i = 0;
  std::cout << MyType{ ++i, ++i, ++i, ++i }.sum << '\n';
}

[Bug c++/70796] [DR 1030] Initialization order with braced-init-lists still broken

2016-04-26 Thread lefticus at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70796

Jason Turner  changed:

   What|Removed |Added

 CC||lefticus at gmail dot com

--- Comment #1 from Jason Turner  ---
Also related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70792