This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/TM4C123GH6PM: Misra C may misinterpreted

Part Number: TM4C123GH6PM
Other Parts Discussed in Thread: CODECOMPOSER

Tool/software: TI C/C++ Compiler

Hello everybody, 

I am just interested in static code analysis based on Misra C guidelines and i have the following warning generated cases which i can't understand. 

warning 1:

I have misra warning says:

" If the bitwise operators ~ and << are applied to an operand of underlying type unsigned char or unsigned short,

the result shall be immediately cast to the underlying type of the operand"

in the following statement:

CAN0_CTL_R &= ~ CAN_CTL_INIT;

where: 

#define CAN_CTL_INIT            0x00000001U  // Initialization
#define CAN0_CTL_R              (*((volatile uint32_t *)0x40040000U))

----------------------------------------------------------------------------------------------------

warning 2:

does any of these may be a bug in the misra tool ? 

Regards, 

Sarea

  • Thank you for bringing these issues to our attention.

    Regarding ...

    sarea hariri said:
    CAN0_CTL_R &= ~ CAN_CTL_INIT;

    I can reproduce the diagnostic.  It appears the compiler is incorrect.  So I filed CODEGEN-4934 in the SDOWP system to have this investigated.  You are welcome to follow it with the SDOWP link below in my signature.

    Regarding the second warning ... I cannot reproduce it based on what I see in the screen shot.  For the file which contains these source lines, please submit a test case as described in the article How to Submit a Compiler Test Case.

    Thanks and regards,

    -George

  • Hello George,

    Thanks for your replay.

    Regarding the second warning test case:

    Compiler version:  TI v16.9.6.LTS [TI v18.1.1.LTS]

    Build  output:

    **** Build of configuration Debug for project AutosarCanStack ****

    "C:\\ti\\ccsv8\\utils\\bin\\gmake" -k -j 8 arch/arm-cortexM4/drivers/Can.obj -O

    Building file: "../arch/arm-cortexM4/drivers/Can.c"

    Invoking: ARM Compiler

    "C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.1.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me --include_path="C:/Users/visitor/Documents/CODECOMPOSER 8/AutosarCanStack" --include_path="C:/ti/TivaWare_C_Series-2.1.4.178" --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.1.LTS/include" --define=PART_TM4C123GH6PM --define=ccs=\"ccs\" -g --gcc --preproc_with_comment --preproc_with_compile --diag_warning=225 --diag_wrap=off --display_error_number --abi=eabi --check_misra="required" --obj_directory="arch/arm-cortexM4/drivers"  "../arch/arm-cortexM4/drivers/Can.c"

    "../arch/arm-cortexM4/drivers/Can.c", line 61: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 61: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 61: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 61: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 61: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 61: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 61: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 61: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 61: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 61: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 61: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 61: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 61: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 61: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 61: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 61: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 68: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 68: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 68: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 68: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 68: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 74: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 74: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 74: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 74: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 74: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 74: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 74: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 74: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 74: warning #1391-D: (MISRA-C:2004 9.2/R) Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures

    "../arch/arm-cortexM4/drivers/Can.c", line 192: warning #1423-D: (MISRA-C:2004 17.6/R) The address of an object with automatic storage shall not be assigned to another object that may persist after the first object has ceased to exist

    "../arch/arm-cortexM4/drivers/Can.c", line 202: warning #1487-D: (MISRA-C:2004 12.2/R) The value of an expression shall be the same under any order of evaluation that the standard permits

    "../arch/arm-cortexM4/drivers/Can.c", line 206: warning #1476-D: (MISRA-C:2004 17.4/R) Array indexing shall be the only allowed form of pointer arithmetic

    "../arch/arm-cortexM4/drivers/Can.c", line 206: warning #1393-D: (MISRA-C:2004 10.1/R) The value of an expression of integer type shall not be implicitly converted to a different underlying type if the expression is complex

    "../arch/arm-cortexM4/drivers/Can.c", line 248: warning #1487-D: (MISRA-C:2004 12.2/R) The value of an expression shall be the same under any order of evaluation that the standard permits

    "../arch/arm-cortexM4/drivers/Can.c", line 273: warning #188-D: pointless comparison of unsigned integer with zero

    "../arch/arm-cortexM4/drivers/Can.c", line 284: warning #1487-D: (MISRA-C:2004 12.2/R) The value of an expression shall be the same under any order of evaluation that the standard permits

    "../arch/arm-cortexM4/drivers/Can.c", line 289: warning #1468-D: (MISRA-C:2004 14.7/R) A function shall have a single point of exit at the end of the function

    "../arch/arm-cortexM4/drivers/Can.c", line 306: warning #1397-D: (MISRA-C:2004 10.5/R) If the bitwise operators ~ and << are applied to an operand of underlying type unsigned char or unsigned short, the result shall be immediately cast to the underlying type of the operand

    "../arch/arm-cortexM4/drivers/Can.c", line 312: warning #1397-D: (MISRA-C:2004 10.5/R) If the bitwise operators ~ and << are applied to an operand of underlying type unsigned char or unsigned short, the result shall be immediately cast to the underlying type of the operand

    "../arch/arm-cortexM4/drivers/Can.c", line 401: warning #1397-D: (MISRA-C:2004 10.5/R) If the bitwise operators ~ and << are applied to an operand of underlying type unsigned char or unsigned short, the result shall be immediately cast to the underlying type of the operand

    "../arch/arm-cortexM4/drivers/Can.c", line 402: warning #1397-D: (MISRA-C:2004 10.5/R) If the bitwise operators ~ and << are applied to an operand of underlying type unsigned char or unsigned short, the result shall be immediately cast to the underlying type of the operand

    "../arch/arm-cortexM4/drivers/Can.c", line 406: warning #1397-D: (MISRA-C:2004 10.5/R) If the bitwise operators ~ and << are applied to an operand of underlying type unsigned char or unsigned short, the result shall be immediately cast to the underlying type of the operand

    "../arch/arm-cortexM4/drivers/Can.c", line 407: warning #1397-D: (MISRA-C:2004 10.5/R) If the bitwise operators ~ and << are applied to an operand of underlying type unsigned char or unsigned short, the result shall be immediately cast to the underlying type of the operand

    "../arch/arm-cortexM4/drivers/Can.c", line 381: warning #1468-D: (MISRA-C:2004 14.7/R) A function shall have a single point of exit at the end of the function

    "../arch/arm-cortexM4/drivers/Can.c", line 469: warning #1476-D: (MISRA-C:2004 17.4/R) Array indexing shall be the only allowed form of pointer arithmetic

    "../arch/arm-cortexM4/drivers/Can.c", line 469: warning #1393-D: (MISRA-C:2004 10.1/R) The value of an expression of integer type shall not be implicitly converted to a different underlying type if the expression is complex

    "../arch/arm-cortexM4/drivers/Can.c", line 447: warning #1468-D: (MISRA-C:2004 14.7/R) A function shall have a single point of exit at the end of the function

    "../arch/arm-cortexM4/drivers/Can.c", line 483: warning #552-D: variable "status_register_reading" was set but never used

    Finished building: "../arch/arm-cortexM4/drivers/Can.c"

    **** Build Finished ****

    Here is the preproccessed file:6170.Can.pp.txt

    Regards, 

    Sarea

  • Thank you for submitting a second test case.  It appears the 12.2 MISRA diagnostics are incorrectly issued.  So, I filed CODEGEN-4943 in the SDOWP system to have this investigated.  As before, you are welcome to follow it with the SDOWP link below in my signature.

    Thanks and regards,

    -George