[llvm-bugs] [Bug 36333] New: Supposedly-incorrect error 'constexpr variable... must be initialized by a constant expression'

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Feb 10 02:55:33 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=36333

            Bug ID: 36333
           Summary: Supposedly-incorrect error 'constexpr variable... must
                    be initialized by a constant expression'
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: sergey.ignatchenko at ithare.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Created attachment 19850
  --> https://bugs.llvm.org/attachment.cgi?id=19850&action=edit
preprocessed source

Preprocessed code attached compiles ok with GCC 7, MSVC, Apple Clang 9.0.0, and
current top-of-the-trunk Clang (after bug #36055 has been fixed). However, with
Clang 5.0.0 and Clang 5.0.1 it issues 

In file included from ../official.cpp:34:
../../src/obf.h:455:25: error: constexpr variable 'split' must be initialized
by
      a constant expression
   ObfDescriptor(true,0,sz4>1?100:0),
   ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~

This doesn't make much sense - as (a) it is indeed about sz4 (replacing it
removes the bug here), and (b) as sz4 has been declared as constexpr just 7
lines above. Also - see above re. the same code being compiled ok with all the
other c++17 compilers (which doesn't qualify as a strict proof, but is a reason
to take a look ;-) ). 

NB: it MIGHT be a different manifestation of recently-fixed bug #36055, but if
so - it would be nice to re-apply the fix back to Clang 5.0.x (which is still
the-latest-greatest-officially-released-Clang). 

Command line:
clang-5.0  -DITHARE_OBF_INIT -DITHARE_OBF_CONSISTENT_XPLATFORM_IMPLICIT_SEEDS
-DITHARE_OBF_ENABLE_AUTO_DBGPRINT -DITHARE_OBF_SEED=0x4b295ebab3333abc
-DITHARE_OBF_SEED2=0x36e007a38ae8e0ea -o obftemp -std=c++1z -lstdc++ -Werror
../official.cpp

-- 
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/20180210/e59f2728/attachment.html>


More information about the llvm-bugs mailing list