Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

[bug report] Variable length array in statement expression

Suzuki__Hajime
Beginner
425 Views

Hi,

I encountered a phenomenon that a statement expression is always evaluated as zero when variable length array is declared inside it. Constant-length array did not cause this problem, including an array whose length is specified by a variable which is qualified as `const`. It reproduced with Intel C Compiler version 13.0.1, 16.0.3, 17.0.0, and 18.0.0 (which were available at https://godbolt.org/ and my environment). It didn't happen with the C++ compiler (icpc). The following is a code that reproduces the situation. Here is a link to the same code at compiler explorer: https://godbolt.org/g/YrNgfb .

#include <stddef.h>
int vla_in_statement_expression(void)
{
    size_t len = 5;
    int a = ({ int vla[len]; 42; });
    return(a);
}

I would appreciate if the compiler team respond to this problem. I'm sorry if it is not a bug but a correct behavior that is described in the document.

Thanks,

Hajime Suzuki

 

0 Kudos
4 Replies
Viet_H_Intel
Moderator
425 Views

 

Thanks for reporting this issue. Let me look into it and get back to you.

Regards,

Viet 

0 Kudos
Viet_H_Intel
Moderator
425 Views

 

I've filed a bug report to our developer. The internal tracking is: CMPLRS-50845. I'll let you know when we have a fix.

Thanks,

Viet

0 Kudos
Suzuki__Hajime
Beginner
425 Views

Thanks! I really appreciate your quick response.

Hajime

0 Kudos
Bekes__Gabor
Beginner
425 Views

Hello,

the reference (version 19 at least) says that 'Variable-length arrays are no longer allowed in statement expressions.'

0 Kudos
Reply