http://llvm.org/bugs/show_bug.cgi?id=16377

            Bug ID: 16377
           Summary: statement expressions do not evaluate as constexpr
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

The statement expressions extension under gcc permits its use in a constexpr
evaluation.  So the following "dummy" code is accepted by gcc:

  struct A { };

  static_assert(({ 1; }), "oops");
  constexpr auto a = ({ A(); });

And this macro which produces a useful diagnostic if used with a non-array
argument also works under gcc:

#define ARRAY_SIZEOF(A) \
  ({ static_assert(std::extent<__typeof__(A)>::value >= 0,          \
                   TO_STRING(A) " is not an array with size >= 0"); \
     std::extent<__typeof__(A)>::value; })

[[The TO_STRING macro isn't given, but it should be fairly clear what it
does!]]

clang unfortunately does not accept any of this code, complaining that it
doesn't constitute a constant expression.  Would it be possible to extend clang
to support this?

Thanks.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to