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

            Bug ID: 69449
           Summary: Some invalid fold expressions incorrectly accepted
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rs2740 at gmail dot com
  Target Milestone: ---

Repro:

struct A { A(int = 0); A operator+(A) const; };
struct B { B(int = 0); operator int() const; };

template<int... Is>
void f(){
    (A() + A() + ... + A(Is)); // compiles!
}

template<int... Is>
void g(){
    (B() + B() + ... + B(Is)); // error: binary expression in operand 
                               //        of fold-expression
}

Both function templates should be rejected, because neither A() + A() nor B() +
B() is a cast-expression, but only the one calling the built-in operator + is.

Reply via email to