Should issue diagnostic when assigning integer constant to a bit-field too small to represent the value

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: Not Prioritized

      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 */
      }
      

            Assignee:
            TI User
            Reporter:
            TI User
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                Connection: Intermediate to External PROD System
                EXTSYNC-3653 - Should issue diagnostic when assign...
                SYNCHRONIZED
                • Last Sync Date: