all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* INT_ADD_OVERFLOW broken?
@ 2013-09-22  0:39 Daniel Colascione
  2013-09-22  6:59 ` Paul Eggert
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Colascione @ 2013-09-22  0:39 UTC (permalink / raw)
  To: Emacs development discussions

[-- Attachment #1: Type: text/plain, Size: 388 bytes --]

When trying to compile this code:

  if (INT_ADD_OVERFLOW ((ptrdiff_t) (bool_header_size - header_size),
                        total_payload_bytes))
    memory_full (SIZE_MAX);

gcc produces this warning:

alloc.c:2051: warning: assuming signed overflow does not occur when
assuming that (X + c) >= X is always true [-Wstrict-overflow]

Is INT_ADD_OVERFLOW actually safe?


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: INT_ADD_OVERFLOW broken?
  2013-09-22  0:39 INT_ADD_OVERFLOW broken? Daniel Colascione
@ 2013-09-22  6:59 ` Paul Eggert
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Eggert @ 2013-09-22  6:59 UTC (permalink / raw)
  To: Daniel Colascione, Emacs development discussions

Daniel Colascione wrote:

> Is INT_ADD_OVERFLOW actually safe?

It's supposed to be, yes.

As I recall, -Wstrict-overflow and -Wtype-limits issue many false
alarms, for INT_ADD_OVERFLOW as well as for other things, so I don't
recommend their use when building GNU Emacs.  That's why
--enable-gcc-warnings doesn't enable these options.

It's possible that you've found a bug in INT_ADD_OVERFLOW;
to check that it'd be helpful to have a self-contained example
so that the problem can be reproduced and understood.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-09-22  6:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-22  0:39 INT_ADD_OVERFLOW broken? Daniel Colascione
2013-09-22  6:59 ` Paul Eggert

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.