Article View: comp.lang.c++
Article #769Re: does an expression in a logical statement need parenthesis for proper evaluation?
From: Lynn McGuire
Date: Fri, 06 Nov 2026 21:37
Date: Fri, 06 Nov 2026 21:37
54 lines
3426 bytes
3426 bytes
On 11/6/2026 12:50 PM, Keith Thompson wrote:
> David Brown <david.brown@hesbynett.no> writes:
>> On 06/11/2026 02:07, Lynn McGuire wrote:
>>> On 11/5/2026 5:42 PM, Lynn McGuire wrote:
>>>> Hi,
>>>>
>>>> Does an expression in a logical statement need parenthesis for
>>>> proper evaluation in C and/or C++?
>>>>
>>>> In other words, should
>>>>
>>>> if (j1 * i1 < 1) {
>>>> goto L463;
>>>> }
>>>>
>>>> be
>>>>
>>>> if ((j1 * i1) < 1) {
>>>> goto L463;
>>>> }
>>>>
>>>> Thanks,
>>>> Lynn
>>> Thank you all very much. BTW, there were parenthesis in the old
>>> Fortran code but F2C stripped them out. I put them back in for my
>>> comfort as I see them.
>>>
>>
>> Since you are generating the C++ code automatically, there should not
>> be a problem adding the parentheses. Generated code that contains
>> "goto L463" is clearly not intended for humans anyway (at least, not
>> without a good deal of effort).
>
> My understanding is that the C++ code being generated is intended to be
> maintained as C++ code. Lynn can confirm or deny that. He's using f2c
> and a lot of manual cleanup.
...
Yes. I am tired of fixing the thousands of Fortran to C calls and C to
Fortran calls when we move to a new Fortran compiler or a new C/C++
compiler. This is one of the problems that has kept us on the obsolete
Watcom F77/C/C++ compilers for over 30 years.
I think I started putting C code into our Fortran calculation engine in
1992 when a Japanese customer needed more memory for their Inline
Fortran code inside our software (we have a Fortran 66 compiler and
interpreter built into our software). I finally gave up giving them a
special version every few months and moved all of the dynamic memory
allocation code to using malloc, realloc, and free. Worked like a champ
on the Unix and PC boxes, not so much on the mainframes and Vax
refrigerators that were going away anyway.
Lynn
Technical Details
Message-ID:
<11clhb0$2tpii$1@dont-email.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<11cj4a0$23796$1@dont-email.me> <11cj994$24m06$1@dont-email.me> <11ck0pr$2amtc$1@dont-email.me> <11cl7i3$2pbh3$1@kst.eternal-september.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Lynn McGuire <lynnmcguire5@gmail.com> Newsgroups: comp.lang.c++,comp.lang.c Subject: Re: does an expression in a logical statement need parenthesis for proper evaluation? Date: Fri, 6 Nov 2026 15:37:33 -0600 Organization: A noiseless patient Spider Lines: 54 Message-ID: <11clhb0$2tpii$1@dont-email.me> References: <11cj4a0$23796$1@dont-email.me> <11cj994$24m06$1@dont-email.me> <11ck0pr$2amtc$1@dont-email.me> <11cl7i3$2pbh3$1@kst.eternal-september.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 06 Nov 2026 21:37:37 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3073618"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19r+KS8/drEZppKjlbrERhzdaYtOdyQdDI="; posting-host="9424d41671042b4b3ea15a90032ad150" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:eeLFmD09wbn/KSL9zzjAQjNM19c= sha256:XBY1bmhOTKkueFnSKXUhjmB5WqAuDSL21xaq5x+tR/c= sha1:A5j9DMgy1yP93pvZu4IgrUPyINc= sha256:1tUCMhkXhrJ6OAwkYJutqXurpQPvafjvrV/JaoSaUIU= In-Reply-To: <11cl7i3$2pbh3$1@kst.eternal-september.org> Content-Language: en-US