Skip to content

[SYCL] error: variable-sized object may not be initialized #887

@cagnulein

Description

@cagnulein

I'm facing a strange compiler issue. The source code are here https://github.com/cagnulein/sycl-benchmarks/blob/fix_2d_array_with_array/rotate/rotate_usm.cpp

Is it supposed to be ok? If yes, how can i use a dynamic multidimensional array with USM?

$ clang++ -O2 -g -std=c++11 -fsycl rotate_usm.cpp -lOpenCL -o rotate_usm.gpu
rotate_usm.cpp:142:100: error: variable-sized object may not be initialized
            cgh.parallel_for(sycl::range<2>(DestBitmapWidth,DestBitmapHeight), [=](sycl::id<2> idx) {
                                                                                                   ^
rotate_usm.cpp:142:99: error: variable-sized object may not be initialized
            cgh.parallel_for(sycl::range<2>(DestBitmapWidth,DestBitmapHeight), [=](sycl::id<2> idx) {
                                                                                                  ^
rotate_usm.cpp:142:99: note: in implicit move constructor for '(lambda at rotate_usm.cpp:142:99)' first required here
rotate_usm.cpp:142:99: error: variable-sized object may not be initialized
            cgh.parallel_for(sycl::range<2>(DestBitmapWidth,DestBitmapHeight), [=](sycl::id<2> idx) {
                                                                                                  ^
/home/sysele/sycl/build/lib/clang/10.0.0/include/CL/sycl/handler.hpp:697:50: note: in implicit copy constructor for '(lambda at rotate_usm.cpp:142:99)' first required here
    kernel_parallel_for(KernelFunc);
                                                 ^
rotate_usm.cpp:142:17: note: in instantiation of function template specialization 'cl::sycl::handler::parallel_for' requested here
            cgh.parallel_for(sycl::range<2>(DestBitmapWidth,DestBitmapHeight), [=](sycl::id<2> idx) {
                ^
error: variable-sized object may not be initialized
rotate_usm.cpp:142:17: note: in instantiation of function template specialization 'cl::sycl::handler::parallel_for' requested here
error: array initializer must be an initializer list
Stack dump:
0.	Program arguments: /home/sysele/sycl/build/bin/clang-10 -cc1 -triple spir64-unknown-unknown-sycldevice -fsycl-is-device -aux-triple x86_64-unknown-linux-gnu -std=c++11 -disable-llvm-passes -sycl-std=1.2.1 -emit-llvm-bc -disable-free -disable-llvm-verifier -discard-value-names -main-file-name rotate_usm.cpp -mrelocation-model static -mthread-model posix -mframe-pointer=all -fmath-errno -mconstructor-aliases -fuse-init-array -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -resource-dir /home/sysele/sycl/build/lib/clang/10.0.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/x86_64-linux-gnu/c++/7.4.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/x86_64-linux-gnu/c++/7.4.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/backward -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/x86_64-linux-gnu/c++/7.4.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/x86_64-linux-gnu/c++/7.4.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/backward -internal-isystem /usr/local/include -internal-isystem /home/sysele/sycl/build/lib/clang/10.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -internal-isystem /usr/local/include -internal-isystem /home/sysele/sycl/build/lib/clang/10.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /home/sysele/work/sycl/rotate -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -o /tmp/rotate_usm-49bd83.o -x c++ rotate_usm.cpp 
1.	 parser at end of file
2.	/home/sysele/sycl/build/lib/clang/10.0.0/include/CL/sycl/handler.hpp:694:8: instantiating function definition 'cl::sycl::handler::parallel_for'
/home/sysele/sycl/build/bin/clang-10(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x2a)[0x55796d2d437a]
/home/sysele/sycl/build/bin/clang-10(_ZN4llvm3sys17RunSignalHandlersEv+0x34)[0x55796d2d2114]
/home/sysele/sycl/build/bin/clang-10(+0x1805252)[0x55796d2d2252]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12890)[0x7f24eba49890]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang12InitListExprC2ERKNS_10ASTContextENS_14SourceLocationEN4llvm8ArrayRefIPNS_4ExprEEES4_+0xa8)[0x55796f563888]
/home/sysele/sycl/build/bin/clang-10(+0x367eff8)[0x55796f14bff8]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang4Sema21ConstructOpenCLKernelEPNS_12FunctionDeclERNS_13MangleContextE+0x10a2)[0x55796f14d902]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang4Sema28PerformPendingInstantiationsEb+0x899)[0x55796f281549]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang4Sema29InstantiateFunctionDefinitionENS_14SourceLocationEPNS_12FunctionDeclEbbb+0xbe1)[0x55796f282231]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang4Sema28PerformPendingInstantiationsEb+0x350)[0x55796f281000]
/home/sysele/sycl/build/bin/clang-10(+0x3185e7f)[0x55796ec52e7f]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang4Sema25ActOnEndOfTranslationUnitEv+0xb6)[0x55796ec53716]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang6Parser17ParseTopLevelDeclERNS_9OpaquePtrINS_12DeclGroupRefEEEb+0x37d)[0x55796eb3d03d]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang8ParseASTERNS_4SemaEbb+0x208)[0x55796eb30b98]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang13CodeGenAction13ExecuteActionEv+0x32)[0x55796df56eb2]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang14FrontendAction7ExecuteEv+0xb9)[0x55796d9e3949]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x1f5)[0x55796d9a45d5]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang25ExecuteCompilerInvocationEPNS_16CompilerInstanceE+0xc9b)[0x55796daa9abb]
/home/sysele/sycl/build/bin/clang-10(_Z8cc1_mainN4llvm8ArrayRefIPKcEES2_Pv+0x6eb)[0x55796c42569b]
/home/sysele/sycl/build/bin/clang-10(main+0x22a2)[0x55796c3c2f82]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7f24ea6ddb97]
/home/sysele/sycl/build/bin/clang-10(_start+0x2a)[0x55796c422f4a]
clang-10: error: unable to execute command: Segmentation fault (core dumped)
rotate_usm.cpp:142:100: error: variable-sized object may not be initialized
            cgh.parallel_for(sycl::range<2>(DestBitmapWidth,DestBitmapHeight), [=](sycl::id<2> idx) {
                                                                                                   ^
rotate_usm.cpp:142:99: error: variable-sized object may not be initialized
            cgh.parallel_for(sycl::range<2>(DestBitmapWidth,DestBitmapHeight), [=](sycl::id<2> idx) {
                                                                                                  ^
rotate_usm.cpp:142:99: note: in implicit move constructor for '(lambda at rotate_usm.cpp:142:99)' first required here
rotate_usm.cpp:142:99: error: variable-sized object may not be initialized
            cgh.parallel_for(sycl::range<2>(DestBitmapWidth,DestBitmapHeight), [=](sycl::id<2> idx) {
                                                                                                  ^
/home/sysele/sycl/build/lib/clang/10.0.0/include/CL/sycl/handler.hpp:697:50: note: in implicit copy constructor for '(lambda at rotate_usm.cpp:142:99)' first required here
    kernel_parallel_for(KernelFunc);
                                                 ^
rotate_usm.cpp:142:17: note: in instantiation of function template specialization 'cl::sycl::handler::parallel_for' requested here
            cgh.parallel_for(sycl::range<2>(DestBitmapWidth,DestBitmapHeight), [=](sycl::id<2> idx) {
                ^
error: variable-sized object may not be initialized
rotate_usm.cpp:142:17: note: in instantiation of function template specialization 'cl::sycl::handler::parallel_for' requested here
error: array initializer must be an initializer list
Stack dump:
0.	Program arguments: /home/sysele/sycl/build/bin/clang-10 -cc1 -triple spir64-unknown-unknown-sycldevice -fsycl-is-device -aux-triple x86_64-unknown-linux-gnu -std=c++11 -disable-llvm-passes -sycl-std=1.2.1 -fsyntax-only -disable-free -disable-llvm-verifier -discard-value-names -main-file-name rotate_usm.cpp -mrelocation-model static -mthread-model posix -mframe-pointer=all -fmath-errno -mconstructor-aliases -fuse-init-array -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -resource-dir /home/sysele/sycl/build/lib/clang/10.0.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/x86_64-linux-gnu/c++/7.4.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/x86_64-linux-gnu/c++/7.4.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/backward -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/x86_64-linux-gnu/c++/7.4.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/x86_64-linux-gnu/c++/7.4.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/backward -internal-isystem /usr/local/include -internal-isystem /home/sysele/sycl/build/lib/clang/10.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -internal-isystem /usr/local/include -internal-isystem /home/sysele/sycl/build/lib/clang/10.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /home/sysele/work/sycl/rotate -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -fsycl-int-header=/tmp/rotate_usm-cbb883.h -faddrsig -o /tmp/rotate_usm-cbb883.h -x c++ rotate_usm.cpp 
1.	 parser at end of file
2.	/home/sysele/sycl/build/lib/clang/10.0.0/include/CL/sycl/handler.hpp:694:8: instantiating function definition 'cl::sycl::handler::parallel_for'
/home/sysele/sycl/build/bin/clang-10(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x2a)[0x5571175f837a]
/home/sysele/sycl/build/bin/clang-10(_ZN4llvm3sys17RunSignalHandlersEv+0x34)[0x5571175f6114]
/home/sysele/sycl/build/bin/clang-10(+0x1805252)[0x5571175f6252]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12890)[0x7f9354e0f890]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang12InitListExprC2ERKNS_10ASTContextENS_14SourceLocationEN4llvm8ArrayRefIPNS_4ExprEEES4_+0xa8)[0x557119887888]
/home/sysele/sycl/build/bin/clang-10(+0x367eff8)[0x55711946fff8]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang4Sema21ConstructOpenCLKernelEPNS_12FunctionDeclERNS_13MangleContextE+0x10a2)[0x557119471902]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang4Sema28PerformPendingInstantiationsEb+0x899)[0x5571195a5549]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang4Sema29InstantiateFunctionDefinitionENS_14SourceLocationEPNS_12FunctionDeclEbbb+0xbe1)[0x5571195a6231]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang4Sema28PerformPendingInstantiationsEb+0x350)[0x5571195a5000]
/home/sysele/sycl/build/bin/clang-10(+0x3185e7f)[0x557118f76e7f]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang4Sema25ActOnEndOfTranslationUnitEv+0xb6)[0x557118f77716]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang6Parser17ParseTopLevelDeclERNS_9OpaquePtrINS_12DeclGroupRefEEEb+0x37d)[0x557118e6103d]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang8ParseASTERNS_4SemaEbb+0x208)[0x557118e54b98]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang14FrontendAction7ExecuteEv+0xb9)[0x557117d07949]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x1f5)[0x557117cc85d5]
/home/sysele/sycl/build/bin/clang-10(_ZN5clang25ExecuteCompilerInvocationEPNS_16CompilerInstanceE+0xc9b)[0x557117dcdabb]
/home/sysele/sycl/build/bin/clang-10(_Z8cc1_mainN4llvm8ArrayRefIPKcEES2_Pv+0x6eb)[0x55711674969b]
/home/sysele/sycl/build/bin/clang-10(main+0x22a2)[0x5571166e6f82]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7f9353aa3b97]
/home/sysele/sycl/build/bin/clang-10(_start+0x2a)[0x557116746f4a]
clang-10: error: unable to execute command: Segmentation fault (core dumped)
clang-10: error: clang frontend command failed due to signal (use -v to see invocation)
clang-10: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 10.0.0 (https://github.com/intel/llvm 9dd68c53358338e1a167be024406d790f5cb6139)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/sysele/sycl/build/bin
clang-10: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang-10: note: diagnostic msg: Error generating preprocessed source(s).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions