delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/02/23/14:49:01

From: "Rossz Vámos-Wentworth" <rossw AT jps DOT net>
Newsgroups: comp.os.msdos.djgpp
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1000222115120 DOT 19089O-100000 AT is>
Subject: Re: More on building a cross compiler - help needed
Date: Tue, 22 Feb 2000 21:06:20 -0800
Lines: 71
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
NNTP-Posting-Host: 209.239.210.176
X-Original-NNTP-Posting-Host: 209.239.210.176
Message-ID: <38b36b83_2@news.jps.net>
X-Trace: 22 Feb 2000 21:09:23 -0800, 209.239.210.176
X-Original-NNTP-Posting-Host: 209.63.224.240
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote in message:

> >      ./libgcc2.c:995: warning: right shift count >= width of type
> >
> > Is this normal?
>
> No, it means that the offending line invokes an undefined behavior.
> I'd suggest to solve this; post the code fragment if you cannot figure
> this out.

This snippet of code produces the messages that follow.  This is repeated a
number of times - once for nearly each floating point function.  This code
is from libgcc2.c.

code begins ---------------------------------
typedef   int SItype __attribute__ ((mode (SI)));
typedef unsigned int USItype __attribute__ ((mode (SI)));
typedef   int DItype __attribute__ ((mode (DI)));
typedef unsigned int UDItype __attribute__ ((mode (DI)));
typedef  float DFtype __attribute__ ((mode (DF)));

// BITS_PER_UNIT is 8

#ifdef L_floatdidf
#define WORD_SIZE (sizeof (SItype) * BITS_PER_UNIT)
#define HIGH_HALFWORD_COEFF (((UDItype) 1) << (WORD_SIZE / 2))
#define HIGH_WORD_COEFF (((UDItype) 1) << WORD_SIZE)

DFtype
__floatdidf (DItype u)
{
  DFtype d;

  d = (SItype) (u >> WORD_SIZE);  // line 995
  d *= HIGH_HALFWORD_COEFF;
  d *= HIGH_HALFWORD_COEFF;
  d += (USItype) (u & (HIGH_WORD_COEFF - 1)); // line 998

  return d;
}
#endif
code ends ---------------------------------------------

Output here:

_floatdidf
./libgcc2.c: In function `__floatdidf':
./libgcc2.c:995: warning: right shift count >= width of type
./libgcc2.c:998: warning: left shift count >= width of type

It's my guess that DItype and SItype are the same, so the bits are lost
despite the typecase.

> > Since they are only warning errors and I don't care about
> > the runtime libraries, I didn't worry.
>
> How so?  libgcc.a is an essential part of the compiler, you might be
> unable to produce executables that can be run on the target without
> libgcc.

I have my own runtime libraries.  None of the original GNU libraries can be
used, anyway (it's an embedded system).

> Add -save-temps to the compiler switches and examine the *.ii files it
> leaves behind.  You will then see what does cc1 see on that line.

All it displayed was the name of the file being compiled.



- Raw text -


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