Menu

False positive: variable name using hexadecimal characters only ending with 'l' will triggers misra-c2012-7.3

cola
2026-01-09
2026-01-13
  • cola

    cola - 2026-01-09
    long al = 1L; // warns
    long fl = 1L; // warns
    long gl = 1L; // ok!
    long abcdefl = 1L;  // warn
    long abcdefgl = 1L; // ok!
    
     
  • Jonathan Forrest

    misra-c2012-7.3 seems to have a few issues....

    My one is that if I have a struct with an element ending in l then when I initialise that struct it throws a warning:

                {
                    .port = eGpioConfigPortA,
                    .pin = 1U,
                    .speed = eGpioConfigDriveLow,
                    .pull = eGpioConfigPullUp,
                    .output_type = eGpioConfigOutputPushPull,
                    .alternate_function = 8U,
                },
    

    Throws:

    config.c:129:18: style: The lowercase character "l" shall not be used in a literal suffix [misra-c2012-7.3]
                    .pull = eGpioConfigPullUp,
                     ^
    

    Figured I would just add this into an existing discussion on the rule rather than making an extra issue as hopefully both issues can be resolved at the same time.
    Also, likely related as the variable name pull also causes 7.3 warnings for me.

     

    Last edit: Jonathan Forrest 2026-01-13

Log in to post a comment.