From: David Sletten <david.paul.sletten@gmail.com>
To: "Alejandro Colomar (man-pages)" <alx.manpages@gmail.com>
Cc: linux-man@vger.kernel.org, mtk.manpages@gmail.com
Subject: Re: Error in 'man operator'
Date: Fri, 27 Aug 2021 20:20:21 -0400 [thread overview]
Message-ID: <2c0b0fb7-1f52-4e7f-86a7-65ec2bf2887d@gmail.com> (raw)
In-Reply-To: <6666465a-ad5d-d8f7-92b1-35733f645961@gmail.com>
Ha. Nice work.
On 8/27/21 8:17 PM, Alejandro Colomar (man-pages) wrote:
> Hi David,
>
> On 8/28/21 2:01 AM, Alejandro Colomar (man-pages) wrote:
>> I mean:
>> !(int)x
>> (int)!x
>>
>> The precedence doesn't matter there, as they apply one after the
>> other, right to left.
>>
>> So, I'll keep casts in row 2.
>
> Hmm, I just came up with some very stupid piece of code that can show
> the different precedence between "unary operators" and "cast operators":
>
> sizeof(int)x;
>
> Which I hope no-one on earth would ever want to be valid C.
>
> If casts had the same precedence as unary operators, this would be:
> First, cast x to int, then apply sizeof to the resulting int (since
> sizeof can be used without parentheses on non-types).
>
> But since sizeof has greater precedence than the cast, it would be:
> First, calculate sizeof(int), then... x? Invalid expression!
>
> And luckily, the second thing happens, and the compiler yells:
>
> sizeof.c: In function ‘foo’:
> sizeof.c:3:20: error: expected ‘;’ before ‘x’
> 3 | return sizeof(int)x;
> | ^
> | ;
>
>
> So I think this deserves a new row.
>
> Thanks!
>
> Alex
>
>>
>> Cheers,
>>
>> Alex
>>
>
>
--
Have all good days!
David Sletten
next prev parent reply other threads:[~2021-08-28 0:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-27 18:11 Error in 'man operator' David Sletten
2021-08-27 23:39 ` Alejandro Colomar (man-pages)
2021-08-28 0:01 ` Alejandro Colomar (man-pages)
2021-08-28 0:08 ` David Sletten
2021-08-28 10:56 ` Alejandro Colomar (man-pages)
2021-08-28 0:17 ` Alejandro Colomar (man-pages)
2021-08-28 0:20 ` David Sletten [this message]
2021-08-28 5:43 ` Jakub Wilk
2021-08-28 10:50 ` Alejandro Colomar (man-pages)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2c0b0fb7-1f52-4e7f-86a7-65ec2bf2887d@gmail.com \
--to=david.paul.sletten@gmail.com \
--cc=alx.manpages@gmail.com \
--cc=linux-man@vger.kernel.org \
--cc=mtk.manpages@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox