Unexpected warning: array subscript has type 'char' [-Wchar-subscripts]

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
kemic_264446
Level 4
Level 4
First like received

 The following piece of code give the error:

   

.\usb_uart.c:210:3: warning: array subscript has type 'char' [-Wchar-subscripts] at the line marked with "****", but as far as I can see the array subscript is int, not char.

   

 

   

 

   
 int i,len;  uint16 c,d;  uint32 ip,u32;  char r,s;  char *pC = 0;  //MSG_BUF *pMB;     // convert entire buffer to UCASE  for(i=0; i<usbRxPos; i++)  {  usbCmdBuffer = toupper(usbCmdBuffer); // ****  }   
0 Likes
5 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Seems to be a bug in strings.h. When I replace toupper with a self-written function no warning is flagged.

   

Best will be  to file a Mycase.

   

 

   

Bob

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Just saw a post from Robyn Weil, you may email the bug-report directly to her: rbyn at cypress dot com.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

I do not see where you have declared "usbCmdBuffer" anywhere. Did a

   

search of your entire workspace, still not found.

   

 

   

Regards, Dana.

0 Likes
RobynW
Employee
Employee
5 likes given First comment on blog 10 likes received

 I've turned this into the developers but haven't heard anything back yet. I'll let you know when I do. -Robyn

0 Likes
kemic_264446
Level 4
Level 4
First like received

 Thanks Bob and Robyn

   

The dfinition of usbCmdBuffer isn't important, since it's the sub-script type it is warning about.

   

I think Bob has found it with the definition of toupper in strings.h

   

I'll dig a bit deeper from this end too.

   

 

   

Thanks again.

0 Likes