🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2554

Re: What are some tricky C questions?

#2554
From: Kazimir Kylheku
Date: Tue, 09 Apr 1996 03:34
23 lines
1371 bytes
In article <4k1pks$514@solutions.solon.com>,
Lawrence Kirby  <fred@genesis.demon.co.uk> wrote:

 >Very little since MAXINT isn't defined. :-) Perhaps if you were to include
 >limits.h and use INT_MAX instead. If you want to add a bit of interest to
 >the problem you could ask the same question about:
 >
 >#include <stddef.h>
 >#include <limits.h>
 >
 >    size_t l;
 >    short i = SHRT_MAX;
 >
 >    l = sizeof(++i);

So what would it be? The result ++i does not undergo intergral promotion. A
better question might be to ask about sizeof(+i), which does force integral
promotion.

This is quite subtle. Both the ++ and the + are defined in the unary-expression
syntactic unit. The only syntactic difference is that the ++ recursively takes
a unary-expression, whereas the + expects a cast-expression.
-- 
Technical Details
Message-ID: <4kclsv$omi@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4jol5v$1qs@solutions.solon.com> <4jttdi$3jm@solutions.solon.com> <4k1pks$514@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
Newsgroups: comp.lang.c.moderated
Subject: Re: What are some tricky C questions?
Date: 8 Apr 1996 22:34:55 -0500
Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4kclsv$omi@solutions.solon.com>
References: <4jol5v$1qs@solutions.solon.com> <4jttdi$3jm@solutions.solon.com> <4k1pks$514@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com