public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Do C++ signed types have modulo semantics?
@ 2005-06-27 14:39 Morten Welinder
  2005-06-27 15:21 ` Gabriel Dos Reis
  0 siblings, 1 reply; 43+ messages in thread
From: Morten Welinder @ 2005-06-27 14:39 UTC (permalink / raw)
  To: gcc

| signed types are undefined on overflow. [5/5] and [3.9.1/2,3]

> But a compiler could define them to be modulo -- that is the whole
> point.  The paragraph does not say they don't "modulo".

True, but you are going to have to deal with the run-time version of

    (int)0x80000000 / -1

which is unpleasant in the sense that Intel processors will trap and not
do anything modulo-like.

Morten

^ permalink raw reply	[flat|nested] 43+ messages in thread
* Do C++ signed types have modulo semantics?
@ 2005-06-27  5:09 Michael Veksler
  2005-06-27 13:02 ` Nathan Sidwell
  0 siblings, 1 reply; 43+ messages in thread
From: Michael Veksler @ 2005-06-27  5:09 UTC (permalink / raw)
  To: gcc





According to the (very) long discussion on VRP, signed char/short/int/etc
do not have modulo semantic, they have an undefined behavior on overflow.
However in <limits> defines numeric_limits<signed type>::is_modulo = true.

1. Is that a bug in <limits>, a bug in the standard, or is just C++
different
   than C in this respect?
2. Maybe because overflow is undefined then is_modulo maybe
   considered "unspecified". I don't like this option, because it does not
help
   generic programming.
3. Do I understand what is_modulo stands for?
4. What should be done (libstdc++ PR, C++ PR, DR, other)?

I have seen this in gcc-4.0-20050602, and gcc-3.4.3



  Michael

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

end of thread, other threads:[~2005-06-30 20:53 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <OF0E4366CA.5D54868B-ON4325702E.0036D351-4325702E.003973C5@il.ibm.com>
     [not found] ` <m3k6keeibo.fsf@uniton.integrable-solutions.net>
2005-06-28 13:29   ` Do C++ signed types have modulo semantics? Nathan Sidwell
2005-06-28 13:59     ` Gabriel Dos Reis
2005-06-28 14:05       ` Nathan Sidwell
2005-06-28 14:05       ` Andrew Pinski
2005-06-28 14:13         ` Gabriel Dos Reis
2005-06-28 15:30           ` Michael Veksler
2005-06-28 15:49             ` Nathan Sidwell
2005-06-28 15:58               ` Michael Veksler
2005-06-28 16:07                 ` Andrew Pinski
2005-06-28 16:39                 ` Gabriel Dos Reis
2005-06-28 15:55             ` Gabriel Dos Reis
2005-06-28 16:47               ` Joseph S. Myers
2005-06-28 17:58                 ` Gabriel Dos Reis
2005-06-27 14:39 Morten Welinder
2005-06-27 15:21 ` Gabriel Dos Reis
  -- strict thread matches above, loose matches on Subject: below --
2005-06-27  5:09 Michael Veksler
2005-06-27 13:02 ` Nathan Sidwell
2005-06-27 14:10   ` Gabriel Dos Reis
2005-06-27 14:36     ` Nathan Sidwell
2005-06-27 14:47       ` Paul Koning
2005-06-27 15:21         ` Michael Veksler
2005-06-28  3:06           ` Mark Mitchell
2005-06-28  3:49             ` Gabriel Dos Reis
2005-06-28 10:08             ` Robert Dewar
2005-06-28 11:19               ` Steven Bosscher
2005-06-28 12:03                 ` Ulrich Weigand
2005-06-28 12:09                   ` Steven Bosscher
2005-06-29 16:46                     ` Steven Bosscher
2005-06-29 18:01                       ` Daniel Berlin
2005-06-29 18:32                         ` Steven Bosscher
2005-06-29 18:45                           ` Robert Dewar
2005-06-29 19:13                         ` Nicholas Nethercote
2005-06-28 12:16                 ` Paul Koning
2005-06-28 12:30                   ` Steven Bosscher
2005-06-28 12:35                     ` Michael Veksler
2005-06-28 12:38                       ` Steven Bosscher
2005-06-28 16:54             ` Joe Buck
2005-06-28 17:02               ` Mark Mitchell
2005-06-28 17:08                 ` Daniel Berlin
2005-06-28 18:12                   ` Mark Mitchell
2005-06-28 17:46                 ` Theodore Papadopoulo
2005-06-27 15:17       ` Gabriel Dos Reis
2005-06-30 20:53         ` Kai Henningsen

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).