tbaederr wrote:

I don't quite get the new diagnostic; sure the variable is initialized no each 
iteration, but the problem at hand is that the initialization itself fails, 
i.e. even if the initializer _is_ constexpr, the implicit variable isn't and 
the initializer fails as well: https://godbolt.org/z/jMMYjEjhz

In fact, the only test we seem to have with for-range loops and a constexpr 
iterator variable is in `test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp`:

```c++
namespace X {
    struct C {
      struct It {
        int val;
        operator int &() { return val; }
      };
      It begin();
      It end();
    };
    constexpr int operator*(const C::It &) { return 0; }
};

void f2() {
  for (constexpr int a : X::C()) {}
}
```
This _does_ work but it seems to be the only construct?

Anyway, this probably goes beyond the scope of the PR and requires someone with 
more knowledge of the spec (shouldn't we make `__begin1` constexpr if `a` is?).


https://github.com/llvm/llvm-project/pull/218145
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to