sqc 0.4.13

Software Code Quality - CERT C compliance checker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/*
 * Rule: INT15-C
 * Source: wiki
 * Status: FAIL - Should trigger INT15-C violation
 * Description: Programmer-defined type cast to unsigned long long may truncate
 */

#include <stdio.h>

typedef unsigned long long mytypedef_t;

void noncompliant(void) {
    mytypedef_t x = 42;
    /* Violation: casting to unsigned long long instead of uintmax_t */
    printf("%llu", (unsigned long long) x);
}