[LLVMbugs] [Bug 16377] New: statement expressions do not evaluate as constexpr

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jun 19 09:36:08 PDT 2013


            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: unassignedclangbugs at nondot.org
          Reporter: andyg1001 at hotmail.co.uk
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    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

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?


You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130619/57c40c06/attachment.html>

More information about the llvm-bugs mailing list