lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lily: fix some type conversion warnings (issue 557190043 by address@


From: Han-Wen Nienhuys
Subject: Re: lily: fix some type conversion warnings (issue 557190043 by address@hidden)
Date: Fri, 24 Jan 2020 09:49:17 +0100

On Thu, Jan 23, 2020 at 10:11 PM David Kastrup <address@hidden> wrote:

> address@hidden writes:
>
> > In LilyPond, the bulk of the warnings come from unsigned 64 bit sizes,
> > ie. vector and list sizes.
> >
> > In order to cause an error, you would have to create vector or list of
> > over 2G of
> > elements (on 32 bit architecture), so the unsigned size would be
> > converted to a negative integer. Since our objects
> > are all larger than a single byte, there isn't enough memory for this to
> > be possible. (The same holds for 64 bit,
> > except that you can't buy machines with that much RAM)
>
> Reality check: my laptop is something like 10 years old and holds 16GB
> of RAM.
>

I meant: you can't buy a machine that has 2^63 bytes of RAM.

The hole in my argument here is that int is 32-bit even on 64-bit
architectures. I have been submersed in the world of the Go programming
language, where things are generally more sane, and "int" mirrors the size
of pointers.

Dan's argument (I think Dan is nine.fierce.ballads?) about the MIDI code is
a good argument to not switch off the -Werror=conversion error. Thanks for
setting me straight on that, Dan.

That said, for typesetting, a 32-bit signed size leaves room for 2e9
entities, and I claim that it is enough for anybody (an A4 page of music
typically 1k objects), so we can freely cast down to 32 bits when we get a
64 bit size_t somewhere. The alternative is that we don't cast it, but pass
on the 64 bit size_t, but every time we do that, we'll create new call
sites where we have to fix up conversions, so that will create more work
for ourselves, while we have many other more pressing issues to attend,
like resolving the GUILE 3 situation.

Thoughts?

-- 
Han-Wen Nienhuys - address@hidden - http://www.xs4all.nl/~hanwen


reply via email to

[Prev in Thread] Current Thread [Next in Thread]