public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/39128]  New: GPC polygon clipping library fails with -O2
@ 2009-02-08  2:16 merkert at comcast dot net
  2009-02-08  2:17 ` [Bug c/39128] " merkert at comcast dot net
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: merkert at comcast dot net @ 2009-02-08  2:16 UTC (permalink / raw)
  To: gcc-bugs

When compiling the popular GPC polygon clipping library
(http://www.cs.man.ac.uk/~toby/alan/software/) with -O2 or -O3 and
then processing a special polygon, it fails with a sigsegv on linux.

The program works fine without optimization and with -O. 
I get the same results with compilers 4.3.2 and 4.3.3, but not with 4.0.2 (at
-O3).

I've run valgrind on the code and it comes back clean and even works!! 

I've attached a the preprocessed source (which is large) from the gcc-4.4. 
This is how it's compile and run:
gcc -O2 -o clip main.i 
gzip -dc polygon.gz | ./clip

I've attached also the full source code.

I'll try to contact the author as well, perhaps there's a problem with the code
when using optimization.


-- 
           Summary: GPC polygon clipping library fails with -O2
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: merkert at comcast dot net
 GCC build triplet: gcc (GCC) 4.4.0 20090130 (experimental)
  GCC host triplet: Linux linux 2.6.11.4-21.17-smp #1 SMP Fri Apr 6 08:42:34
                    UTC 200
GCC target triplet: gcc (GCC) 4.4.0 20090130 (experimental)


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


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

* [Bug c/39128] GPC polygon clipping library fails with -O2
  2009-02-08  2:16 [Bug c/39128] New: GPC polygon clipping library fails with -O2 merkert at comcast dot net
@ 2009-02-08  2:17 ` merkert at comcast dot net
  2009-02-08  2:18 ` merkert at comcast dot net
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: merkert at comcast dot net @ 2009-02-08  2:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from merkert at comcast dot net  2009-02-08 02:17 -------
Created an attachment (id=17268)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17268&action=view)
Preprocessed source

Compile like this: 
gcc -O2 main.i -o clip


-- 


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


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

* [Bug c/39128] GPC polygon clipping library fails with -O2
  2009-02-08  2:16 [Bug c/39128] New: GPC polygon clipping library fails with -O2 merkert at comcast dot net
  2009-02-08  2:17 ` [Bug c/39128] " merkert at comcast dot net
@ 2009-02-08  2:18 ` merkert at comcast dot net
  2009-02-08  2:19 ` merkert at comcast dot net
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: merkert at comcast dot net @ 2009-02-08  2:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from merkert at comcast dot net  2009-02-08 02:18 -------
Created an attachment (id=17269)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17269&action=view)
The data file that causes the core dump

run like this:

gzip -dc polygon.gz | ./clip


-- 


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


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

* [Bug c/39128] GPC polygon clipping library fails with -O2
  2009-02-08  2:16 [Bug c/39128] New: GPC polygon clipping library fails with -O2 merkert at comcast dot net
  2009-02-08  2:17 ` [Bug c/39128] " merkert at comcast dot net
  2009-02-08  2:18 ` merkert at comcast dot net
@ 2009-02-08  2:19 ` merkert at comcast dot net
  2009-02-08  2:49 ` merkert at comcast dot net
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: merkert at comcast dot net @ 2009-02-08  2:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from merkert at comcast dot net  2009-02-08 02:19 -------
Created an attachment (id=17270)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17270&action=view)
Full source code

Full source code, including main.i and gpc code and the polygon that causes the
core dump.


-- 


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


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

* [Bug c/39128] GPC polygon clipping library fails with -O2
  2009-02-08  2:16 [Bug c/39128] New: GPC polygon clipping library fails with -O2 merkert at comcast dot net
                   ` (2 preceding siblings ...)
  2009-02-08  2:19 ` merkert at comcast dot net
@ 2009-02-08  2:49 ` merkert at comcast dot net
  2009-02-08 10:25 ` rguenth at gcc dot gnu dot org
  2009-02-26 23:36 ` [Bug target/39128] " pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 8+ messages in thread
From: merkert at comcast dot net @ 2009-02-08  2:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from merkert at comcast dot net  2009-02-08 02:48 -------
I just found out that it compiles at -O2 if I also specify -ffloat-store. So,
I'm thinking it might be related to that old bug
(http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323), which would not entirely be
a surprise. It's always an issue for any non-trivial piece of math code. 


-- 


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


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

* [Bug c/39128] GPC polygon clipping library fails with -O2
  2009-02-08  2:16 [Bug c/39128] New: GPC polygon clipping library fails with -O2 merkert at comcast dot net
                   ` (3 preceding siblings ...)
  2009-02-08  2:49 ` merkert at comcast dot net
@ 2009-02-08 10:25 ` rguenth at gcc dot gnu dot org
  2009-02-26 23:36 ` [Bug target/39128] " pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-02-08 10:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2009-02-08 10:25 -------
>From the comments I suggest the code does floating point equality compares,
which is a dangerous thing to do if you are not knowing what you do.  A fix
is to instead of x == y use fabs(x - y) <= epsilon.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  GCC build triplet|gcc (GCC) 4.4.0 20090130    |
                   |(experimental)              |
   GCC host triplet|Linux linux 2.6.11.4-21.17- |
                   |smp #1 SMP Fri Apr 6        |
                   |08:42:34 UTC 200            |
 GCC target triplet|gcc (GCC) 4.4.0 20090130    |
                   |(experimental)              |


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


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

* [Bug target/39128] GPC polygon clipping library fails with -O2
  2009-02-08  2:16 [Bug c/39128] New: GPC polygon clipping library fails with -O2 merkert at comcast dot net
                   ` (4 preceding siblings ...)
  2009-02-08 10:25 ` rguenth at gcc dot gnu dot org
@ 2009-02-26 23:36 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-02-26 23:36 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |normal
          Component|c                           |target


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


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

* [Bug target/39128] GPC polygon clipping library fails with -O2
       [not found] <bug-39128-4@http.gcc.gnu.org/bugzilla/>
@ 2021-05-31  3:46 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-05-31  3:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39128

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE
      Known to fail|                            |

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
As mentioned -ffloat-store works so marking this as a dup of bug 323.  32bit
x86 is less important these days too.

*** This bug has been marked as a duplicate of bug 323 ***

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

end of thread, other threads:[~2021-05-31  3:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-08  2:16 [Bug c/39128] New: GPC polygon clipping library fails with -O2 merkert at comcast dot net
2009-02-08  2:17 ` [Bug c/39128] " merkert at comcast dot net
2009-02-08  2:18 ` merkert at comcast dot net
2009-02-08  2:19 ` merkert at comcast dot net
2009-02-08  2:49 ` merkert at comcast dot net
2009-02-08 10:25 ` rguenth at gcc dot gnu dot org
2009-02-26 23:36 ` [Bug target/39128] " pinskia at gcc dot gnu dot org
     [not found] <bug-39128-4@http.gcc.gnu.org/bugzilla/>
2021-05-31  3:46 ` pinskia 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).