public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/50865] New: Invalid code generation for INT64_MIN % -1 on x86_64
@ 2011-10-25 14:25 jaak at ristioja dot ee
  2011-10-25 14:31 ` [Bug c/50865] Invalid code generation for INT64_MIN % 1 " jaak at ristioja dot ee
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: jaak at ristioja dot ee @ 2011-10-25 14:25 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50865

             Bug #: 50865
           Summary: Invalid code generation for INT64_MIN % -1 on x86_64
    Classification: Unclassified
           Product: gcc
           Version: 4.5.3
            Status: UNCONFIRMED
          Severity: blocker
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jaak@ristioja.ee


/*
 * Compiled under 64-bit enviroments with: -O0 -std=c99 -pedantic
 * Happens with GCC 4.5.3 on Gentoo, 4.4.5 on Debian and Apple's 4.2.1 on Mac.
 * The error does not appear when compiler is passed -m32.
 */

#include <inttypes.h>
#include <stdio.h>

#define PRINT_INT64(n, x) printf("(" #n ") r = %" PRId64 "\n", x)

int main(void) {

    /* (1) No crash: */
    PRINT_INT64(1, INT64_MIN % 1);

    /* (2) No crash: */
    {
      volatile int64_t m1 = 1;
      PRINT_INT64(2, INT64_MIN % m1);
    }

    /* (3) No crash: */
    {
      volatile int64_t m2 = -1;
      if (m2 == -1)
          PRINT_INT64(3, INT64_MIN % 1);
      else
          PRINT_INT64(3, INT64_MIN % -m2);
    }

    /* (4) Crash: */
    {
      volatile int64_t m3 = -1;
      PRINT_INT64(4, INT64_MIN % -m3);
    }

    return 0;
}


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

end of thread, other threads:[~2015-06-23  8:40 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-25 14:25 [Bug c/50865] New: Invalid code generation for INT64_MIN % -1 on x86_64 jaak at ristioja dot ee
2011-10-25 14:31 ` [Bug c/50865] Invalid code generation for INT64_MIN % 1 " jaak at ristioja dot ee
2011-10-25 14:57 ` joseph at codesourcery dot com
2011-10-25 15:14 ` jaak.randmets at cyber dot ee
2011-10-25 15:53 ` joseph at codesourcery dot com
2011-10-25 15:56 ` joseph at codesourcery dot com
2011-10-25 16:01 ` [Bug tree-optimization/50865] " jsm28 at gcc dot gnu.org
2011-10-25 16:08 ` jaak at ristioja dot ee
2011-10-25 16:18 ` joseph at codesourcery dot com
2011-10-25 16:38 ` jaak at ristioja dot ee
2011-10-25 17:14 ` joseph at codesourcery dot com
2014-12-10  8:40 ` [Bug middle-end/50865] " mpolacek at gcc dot gnu.org
2014-12-19 13:35 ` jakub at gcc dot gnu.org
2014-12-23 17:50 ` mikpelinux at gmail dot com
2014-12-23 19:51 ` Joost.VandeVondele at mat dot ethz.ch
2014-12-24 12:17 ` mikpelinux at gmail dot com
2015-06-23  8:40 ` rguenth at gcc dot gnu.org

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