Re: -Wstring-plus-int

2022-05-23 Thread Stuart Cassoff

Hi,

   -- Original Message --
   From: t...@theobuehler.org
   To: 3...@bell.net
Cc: ports@openbsd.org
   Sent: Saturday, May 21, 2022 3:14 AM
   Subject: Re: -Wstring-plus-int

 On Fri, May 20, 2022 at 04:34:22AM -0400, Stuart Cassoff 
wrote:

 >
 > I get 7 of these warnings building Tclthread (summarized):
 > warning: adding 'int' to a string does not append to the string
 > [-Wstring-plus-int]
 > Happens here at  "b+1": ((a) && (b) && (*(a)==*(b)) && 
(*(a+1)==*(b+1)) &&

 > (!strcmp((a),(b
 > So I'm wondering if I should:
 > a) Add -Wno-string-plus-int to flags.
 > b) Patch:
 > -  ((a) && (b) && (*(a)==*(b)) && (*(a+1)==*(b+1)) && 
(!strcmp((a),(b
 > +  ((a) && (b) && (*(a)==*(b)) && (*(a+1)==(b[1])) && 
(!strcmp((a),(b


 If you want to patch, I suggest you pull in the upstream fix. This has
 the benefit of consistency and using correct parentheses:


https://github.com/tcltk/thread/commit/4db6b62efaee4a6f3af1f4fe89ef47f59c7dcbb5

I was mistakenly working with an older version.
The newer version has the fix - with the all the brackets.

 Your suggested patch would break reasonable usage such as OPT_CMP(a + 
1, b + 1).


True. It was a surgical patch to handle the particular case.

As a C programmer, I don't think I should be forced into a particular
syntax to add an int to a pointer. I suspect C++ people.

 > c) Leave as is.

 I think either option is fine.


Thanks,

Stu



Re: -Wstring-plus-int

2022-05-21 Thread Theo Buehler
On Fri, May 20, 2022 at 04:34:22AM -0400, Stuart Cassoff wrote:
> 
> I get 7 of these warnings building Tclthread (summarized):
> warning: adding 'int' to a string does not append to the string
> [-Wstring-plus-int]
> Happens here at  "b+1": ((a) && (b) && (*(a)==*(b)) && (*(a+1)==*(b+1)) &&
> (!strcmp((a),(b
> So I'm wondering if I should:
> a) Add -Wno-string-plus-int to flags.
> b) Patch:
> -  ((a) && (b) && (*(a)==*(b)) && (*(a+1)==*(b+1)) && (!strcmp((a),(b
> +  ((a) && (b) && (*(a)==*(b)) && (*(a+1)==(b[1])) && (!strcmp((a),(b

If you want to patch, I suggest you pull in the upstream fix. This has
the benefit of consistency and using correct parentheses:

https://github.com/tcltk/thread/commit/4db6b62efaee4a6f3af1f4fe89ef47f59c7dcbb5

Your suggested patch would break reasonable usage such as OPT_CMP(a + 1, b + 1).

> c) Leave as is.

I think either option is fine.



-Wstring-plus-int

2022-05-20 Thread Stuart Cassoff



I get 7 of these warnings building Tclthread (summarized):
warning: adding 'int' to a string does not append to the string 
[-Wstring-plus-int]
Happens here at  "b+1": ((a) && (b) && (*(a)==*(b)) && (*(a+1)==*(b+1)) 
&& (!strcmp((a),(b

So I'm wondering if I should:
a) Add -Wno-string-plus-int to flags.
b) Patch:
-  ((a) && (b) && (*(a)==*(b)) && (*(a+1)==*(b+1)) && 
(!strcmp((a),(b
+  ((a) && (b) && (*(a)==*(b)) && (*(a+1)==(b[1])) && 
(!strcmp((a),(b

c) Leave as is.

Stu