public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Error with 'typedef' and 'long _Fract'
@ 2008-06-11 20:40 Jeff Kuskin
  0 siblings, 0 replies; only message in thread
From: Jeff Kuskin @ 2008-06-11 20:40 UTC (permalink / raw)
  To: gcc

I am writing a new backend for GCC 4.3.1 and have run into the
following issue with GCC 4.3.1's support for the
fixed-point 'long _Fract' type when used in a 'typedef'.
I believe this issue is generic to GCC and not to the backend.

See the (very short) testcase below and the output from GCC.
Basically: when I use a 'typedef' for the 'long _Fract' type,
GCC generates an error but when I replace the typedef with
a #define that, at least in this case, leads to equivalent
code, GCC completes without error (and the resulting .s file
contains correct assembly).

It seems as if the typedef is not being handled correctly.
Or am I misunderstanding something?


% cat foo.c
#ifdef USE_TYPEDEF
  /* Error occurs when this typedef is used */
  typedef long _Fract fract32_t;
#else
  /* Error does NOT occur when this define is used */
  #define fract32_t long _Fract
#endif

fract32_t foo(fract32_t a)
{
    return a + 0.25lr;
}



% gcc -DUSE_TYPEDEF -O3 foo.c
foo.c: In function 'foo':
foo.c:11: sorry, unimplemented: GCC cannot support operators with
integer types and fixed-point types that have too many integral and
fractional bits together
foo.c:11: error: invalid operands to binary + (have 'fract32_t' and
'long _Fract')


% gcc -O3 foo.c
<no errors>




      

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-06-11 20:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-11 20:40 Error with 'typedef' and 'long _Fract' Jeff Kuskin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).