delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/08/04/07:37:16

Date: Sat, 04 Aug 2001 14:37:06 +0300
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
Message-Id: <7458-Sat04Aug2001143706+0300-eliz@is.elta.co.il>
X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.9
CC: djgpp-workers AT delorie DOT com
In-reply-to: <3B6BC349.946B4D25@phekda.freeserve.co.uk> (message from Richard
Dawe on Sat, 04 Aug 2001 10:41:29 +0100)
Subject: Re: ls bug
References: <200107121836 DOT UAA09468 AT father DOT ludd DOT luth DOT se> <3B6BC349 DOT 946B4D25 AT phekda DOT freeserve DOT co DOT uk>
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> Date: Sat, 04 Aug 2001 10:41:29 +0100
> From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
> 
> 'ls' casts st_size to an unsigned type - uintmax_t - which is defined to
> be unsigned long long:
> 
> if (S_ISCHR (f->stat.st_mode) || S_ISBLK (f->stat.st_mode))
>   sprintf (p, "%3u, %3u ", (unsigned) major (f->stat.st_rdev),
>            (unsigned) minor (f->stat.st_rdev));
> else
>   {
>     char hbuf[LONGEST_HUMAN_READABLE + 1];
>     sprintf (p, "%8s ",
>              human_readable ((uintmax_t) f->stat.st_size, hbuf, 1,
>                              output_block_size < 0 ? output_block_size :
> 1));
>   }
> 
> This cast does not work. This seems strange - I would expect a cast from
> signed long to unsigned long long to work. Wouldn't the value be
> zero-extended to fill the unsigned long long? Does anyone have any
> suggestions on how I can fix this? (I don't have any of my C reference
> material here.) Typecasting to unsigned long then uintmax_t seems to work,
> but I think that's a hack rather than the solution.

Going through unsigned long would be something I'd suggest as well.
I'm not enough of a language lawyer to say whether this is a GCC bug.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019