[EXT_EP-11008] Should issue diagnostic when assigning integer constant to a bit-field too small to represent the value Created: 20/Dec/22 Updated: 20/Oct/25 |
|
| Status: | On Hold |
| Project: | Embedded Software & Tools |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Enhancement | Priority: | Not Prioritized |
| Reporter: | TI User | Assignee: | TI User |
| Resolution: | Unresolved | Votes: | 0 |
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Product: | Code Generation Tools |
| Internal ID: | CODEGEN-10710 |
| Forum URL: | https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/81/t/1181797 |
| Found In Release: | C2000_22.6.0.LTS |
| Affected Platform/Device: | default |
| Description |
|
The compiler should emit a warning that an integer conversion resulted in truncation when assigning an integer constant to a bit-field that is too small to hold the integer value. The compiler does not emit a warning when the declared type of the bit-field is big enough to hold the integer value, even though the actual bit-field might be too small to represent the value. #include <stdint.h>
struct
{
uint32_t hi:16;
uint32_t lo:16;
} s;
void foo()
{
uint16_t l = 0x10000U;
s.lo = 0x10000U; /* should get the same warning, but doesn't */
}
|