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

            Bug ID: 26738
           Summary: clang-cl fails to compile atlctrlw.h header from WTL
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: andreybokha...@gmail.com
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

A small reproducer is:

class CCommandBarCtrlImpl {
public:
  enum { _nMaxMenuItemTextLength = 100 };
};

void foo(CCommandBarCtrlImpl *pT) {
  char szString[pT->_nMaxMenuItemTextLength] = { 0 };
}


$ clang-cl H:/aero.cpp -c
H:/aero.cpp(7,17) :  error: variable-sized object may not be initialized
  char szString[pT->_nMaxMenuItemTextLength] = { 0 };
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.


Both MS and GCC compilers compile the test fine:

$ cl H:/aero.cpp -c
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

aero.cpp

$ echo $?
0


This construct is used in atlctrlw.h header from Windows Template Library:
(https://sourceforge.net/p/wtl/code/HEAD/tree/trunk/wtl/Include/atlctrlw.h#l1309):

TCHAR szString[pT->_nMaxMenuItemTextLength] = { 0 };

nMaxMenuItemTextLength is defined at line 239 of the same header:

enum
{
        _nMaxMenuItemTextLength = 100,
        _chChevronShortcut = _T('/')
};

Yours,
Andrey
======
Software Engineer
Intel Compiler Team

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to