09-28-2015 02:08 AM
Hi,
while editing I produced something like
#include <cvirte.h> int main (int argc, char *argv[]) { if (InitCVIRTE (0, argv, 0) == 0) return -1; /* out of memory */ return 0; char c[2]; }
which CVI 2015's Clang doesn't like:
Build Status (clang-crash.prj - Debug) clang-crash.c - 2 warnings 10, 8 warning: unused variable 'c' 10, 3 warning: will never be executed 1, 1 Instruction referencing instruction not embedded in a basic block! 1, 1 %c = alloca [2 x i8], align 1 1, 1 <badref> = bitcast [2 x i8]* %c to i8*, !dbg <badref> 1, 1 Instruction referencing instruction not embedded in a basic block! 1, 1 %9 = alloca { i8*, i32 }, align 8 1, 1 <badref> = bitcast { i8*, i32 }* %9 to %"type 0x10471e8"*, !dbg <badref> 1, 1 Instruction referencing instruction not embedded in a basic block! 1, 1 %11 = load i8** %1 1, 1 <badref> = call i8 @_InitPtrInfo(i8* %11, %"type 0x1047298"* @__cvi_TN8, %"type 0x10471e8"* <badref>, i8* <badref>), !dbg <badref> 1, 1 Broken module found, compilation aborted! 1, 1 This application has requested the Runtime to terminate it in an unusual way. 1, 1 Please contact the application's support team for more information. Build failed.
This doesn't crash with CVI 2013.
Time for a Service Pack? I still miss my #pragma messages...
Thanks.
09-28-2015 03:32 AM
Hello CVI-User!
Thank you for reporting this issue! The crash seems to be caused in debug configuration when an array is declared after a return statement. I have filed CAR #548267 to be addressed in an upcoming release.
Best regards!
- Johannes
09-28-2015 06:56 AM - edited 09-28-2015 06:58 AM
While clang and gcc (except when using -std=c89) do support the C99 standard of declaring variables anywhere in the code (obviously something in the CVI implementation of clang got screwed here) it's still not a good idea to use that if you ever intend to move your code to other compilers/platforms. Visual C for one thing still doesn't support this for C compiled modules (it does allow it for cpp files or when told to compile the code as C++). Many embedded device compilers don't support it either.
09-28-2015 08:07 AM
Thank you for your reply, Rolf. I agree with you on that.
In my defense the array was inside an if{ } block and while editing I deleted the if. The code above is just the minimal case that crashes Clang. Having { char c[2]; } makes Clang crash, too.
N.B.: VS 2015 does compile such things now as C code.
09-28-2015 09:43 AM
Haven't played with VS C 2015 yet. Still mostly using VS 2010 and even sometimes older ones for NI Pharlap RT compatibility and other compatibility reasons. MS likes to throw in wrenches with every new version to make it harder to run resulting executables on older OS versions.
08-23-2016 02:44 AM - last edited on 07-12-2024 08:21 AM by Content Cleaner
Hi CVI-User,
The issue described by CAR #548267 has been addressed by the LabWindows/CVI 2015 SP1. Information about other bug fixes in this release can be found at: https://www.ni.com/en/support/documentation/bugs/16/labwindows--cvi--2015-sp1-bug-fixes.html
The update is available for download via NI Update Service.
Best regards,
- Johannes