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.

TMS320F28379D: Shift count is too large !!

Part Number: TMS320F28379D


Hello Team TI, 

I have a few errors based on the warnings below:

Errors: Description Resource Path Location Type
#1851 case label value has already appeared in this switch at line 275 
#1851 case label value has already appeared in this switch at line 275 
#1851 case label value has already appeared in this switch at line 275 
#1851 case label value has already appeared in this switch at line 275 
#1851 case label value has already appeared in this switch at line 276 
#1851 case label value has already appeared in this switch at line 276
#1851 case label value has already appeared in this switch at line 276 
#1851 case label value has already appeared in this switch at line 276 
#1851 case label value has already appeared in this switch at line 277
#1851 case label value has already appeared in this switch at line 277
#1851 case label value has already appeared in this switch at line 277
#1851 case label value has already appeared in this switch at line 278 
#1851 case label value has already appeared in this switch at line 278 
#1851 case label value has already appeared in this switch at line 279

Warnings: 
#64-D shift count is too large 
#64-D shift count is too large 
#64-D shift count is too large 
#64-D shift count is too large 
#64-D shift count is too large 
#64-D shift count is too large 
#64-D shift count is too large 
#69-D integer conversion resulted in a change of sign 

The code due to which the errors and warnings are created as below:

 

enum XYZ
{
     A  = 1<< 0
    ,B  = 1<< 1
    ,C  = 1<< 2
    ,D  = 1<< 3
    ,E  = 1<< 4
    ,F  = 1<< 5
    ,G  = 1<< 6
    ,H  = 1<< 7
    ,I  = 1<< 8
    ,J  = 1<< 9
    ,K  = 1<<10
    ,L  = 1<<11
    ,M  = 1<<12
    ,N  = 1<<13
    ,O  = 1<<14
    ,P  = 1<<15
    ,Q  = 1<<16
    ,R  = 1<<17
    ,S  = 1<<18
    ,T  = 1<<19
    ,U  = 1<<20
    ,V  = 1<<21
    ,W  = 1<<22
};


inline const char* ANYNAME(unsigned FOREXSTATUS)
{
    const char* CONSTValue = "UNKNOWN";

    switch(FOREXSTATUS)
    {
    case A: CONSTValue = "A"; break;
    case B: CONSTValue = "B"; break;
    case C: CONSTValue = "C"; break;
    case D: CONSTValue = "D"; break;
    case E: CONSTValue = "E"; break;
    case F: CONSTValue = "F"; break;
    case G: CONSTValue = "G"; break;
    case F: CONSTValue = "F"; break;
    case H: CONSTValue = "H"; break;
    case I: CONSTValue = "I"; break;
    case J: CONSTValue = "J"; break;
    case K: CONSTValue = "K"; break;
    case L: CONSTValue = "L"; break;
    case M: CONSTValue = "M"; break;
    case N: CONSTValue = "N"; break;
    case O: CONSTValue = "O"; break;
    case P: CONSTValue = "P"; break;
    case Q: CONSTValue = "Q"; break;
    case R: CONSTValue = "R"; break;
    case S: CONSTValue = "S"; break;
    case T: CONSTValue = "T"; break;
    case U: CONSTValue = "U"; break;
    case V: CONSTValue = "V"; break;
    }

    return CONSTValue;
}

The problem is I can't change the type of the variable in the header file, due to which there are errors. The other projects are using the same header file but the different compilers and work well. 

Even after typecasting 1 to UL, removes the warnings but not the errors. because there is enum size is 16 bit by default?

How can I change the enum size to 32 or bigger ?

So, what could be the solution to take care of this kind of error? 

Thanks, 

VP 

  • You have to ...

    typecasting 1 to UL

    ... because the standards say the result of a shift operation is undefined if the value of the right operand (the shift count) is greater than or equal to the number of bits of the left operand's type.  The default type of the integer constant 1 is int, which is 16-bits wide.  

    Even once that change is made, there are two other problems with this source code.

    One ... case F appears twice, on lines 40 and 42.

    Two ... The function argument FOREXITSTATUS is unsigned, which is a 16-bit wide type.  It can never equal any of the enumeration constants which are wider than that.  Thus the diagnostics.  When I change FOREXITSTATUS to unsigned long, only one diagnostic appears.  And that is a warning about the inline function ANYNAME never being called.

    Thanks and regards,

    -George

  • Hi George, 

    Thank you for the reply. 

    One ... case F appears twice, on lines 40 and 42.

    This was my typing mistake and I apologize for that but I checked the code and it is not repeating. 

    You have to ...

    Actually, I opened this thread because I can not modify the header file, so I was looking for some code composer settings (if there are any) to change the size of the 'enum', as in the thread below. I am using compiler v20.2.2.LTS, with CCS10. 

    e2e.ti.com/.../2534249

    Also because the GCC compiler is not giving an error. 

    regards, 

    VP

  • I was looking for some code composer settings (if there are any) to change the size of the 'enum'

    Unfortunately, there are no such settings.  For the details, please search the C28x compiler manual for the sub-chapter titled Size of Enum Types.  

    the GCC compiler is not giving an error. 

    It is likely, for this GCC compiler, the size of the built-in type int is 32-bits.  For the C28x compiler, the size of int is 16-bits.

    Thanks and regards,

    -George

  • Okay, thanks, George.