From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CVI2015 Clang crash: Instruction referencing instruction not embedded in a basic block!

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.

-----------------------
/* Nothing past this point should fail if the code is working as intended */
0 Kudos
Message 1 of 6
(4,949 Views)

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

0 Kudos
Message 2 of 6
(4,942 Views)

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.

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 6
(4,933 Views)

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.

-----------------------
/* Nothing past this point should fail if the code is working as intended */
0 Kudos
Message 4 of 6
(4,920 Views)

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.

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 6
(4,911 Views)

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: http://www.ni.com/product-documentation/53302/en/

The update is available for download via NI Update Service.

 

Best regards,

- Johannes

0 Kudos
Message 6 of 6
(3,786 Views)