[Bug c++/59729] [DR1732] C++11 allows type definitions in conditions and for-range-declarations, but shouldn't

harald at gigawatt dot nl gcc-bugzilla@gcc.gnu.org
Wed Jan 8 20:58:00 GMT 2014


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

Harald van Dijk <harald at gigawatt dot nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|C++11 allows type           |[DR1732] C++11 allows type
                   |definitions in conditions   |definitions in conditions
                   |                            |and for-range-declarations,
                   |                            |but shouldn't

--- Comment #1 from Harald van Dijk <harald at gigawatt dot nl> ---
As it turns out, this was indeed accidental, and GCC's and clang's behaviour is
what's intended for conditions, according to
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1732. However,
according to that, the intent is to also disallow type definitions in
for-range-declarations, where GCC currently does permit them (and clang rejects
them).

struct S {
  template <typename T>
  operator T() { return T(); }
};

int main() {
  S s[1];
  for (struct T { } t : s) { }
}

Perhaps this should be suspended until the wording is fixed, and reevaluated at
that time?



More information about the Gcc-bugs mailing list