[Bug c++/38045] New: floating point exception triggered incorrectly

2008-11-06 Thread cstankevitz at toyon dot com
GCC version and linux distribution:
g++ (Gentoo 4.3.2 p1.1) 4.3.2
g++ (GCC) 4.3.0 20080428 (Red Hat 4.3.0-8)
g++ (Ubuntu 4.3.2-1ubuntu11) 4.3.2

Command line to trigger bug:
g++ crash.cpp -O2

Compiler output:
(none)

Executable input:
./a.out

Executable output:
Floating point exception 

Source file attached along with preprocessed file


-- 
   Summary: floating point exception triggered incorrectly
   Product: gcc
   Version: 4.3.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: cstankevitz at toyon dot com


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



[Bug c++/38045] floating point exception triggered incorrectly

2008-11-06 Thread cstankevitz at toyon dot com


--- Comment #1 from cstankevitz at toyon dot com  2008-11-07 05:48 ---
Created an attachment (id=16630)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16630&action=view)
Source


-- 


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



[Bug c++/38045] floating point exception triggered incorrectly

2008-11-06 Thread cstankevitz at toyon dot com


--- Comment #2 from cstankevitz at toyon dot com  2008-11-07 05:48 ---
Created an attachment (id=16631)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16631&action=view)
Preprocessed source


-- 


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



[Bug c++/38045] floating point exception triggered when it shouldn't be

2008-11-06 Thread cstankevitz at toyon dot com


--- Comment #3 from cstankevitz at toyon dot com  2008-11-07 05:50 ---
BTW, the invalid floating point exception is not triggered in g++-4.1.2 (GCC)
4.1.2 (Gentoo 4.1.2 p1.1)


-- 

cstankevitz at toyon dot com changed:

   What|Removed |Added

Summary|floating point exception|floating point exception
   |triggered incorrectly   |triggered when it shouldn't
   ||be


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



[Bug c++/38045] floating point exception triggered when it shouldn't be

2008-11-06 Thread cstankevitz at toyon dot com


--- Comment #5 from cstankevitz at toyon dot com  2008-11-07 07:01 ---
I should have added... the three instances of crashing are on 64 bit OS.  The
gentoo example above:

[EMAIL PROTECTED] ~/delete $ uname -a
Linux crs 2.6.25-gentoo-r7 #17 SMP Sun Nov 2 12:50:21 PST 2008 x86_64 Intel(R)
Core(TM)2 Quad CPU Q9650 @ 3.00GHz GenuineIntel GNU/Linux


-- 


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



[Bug c++/38045] floating point exception triggered when it shouldn't be

2008-11-06 Thread cstankevitz at toyon dot com


--- Comment #8 from cstankevitz at toyon dot com  2008-11-07 07:44 ---
Any recommendation on how to work around it with GCC 4.3.2?  Seemingly
unrelated code changes make it go away.  Thanks - Chris.


-- 


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



[Bug c++/46806] New: -O3 implies 0 <= 8 <= 7

2010-12-04 Thread cstankevitz at toyon dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46806

   Summary: -O3 implies 0 <= 8 <= 7
   Product: gcc
   Version: 4.5.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: cstankev...@toyon.com
  Host: Linux seymour.toyon.corp 2.6.35.6-48.fc14.x86_64 #1
SMP Fri Oct 22 15:36:08 UTC 2010 x86_64 x86_64 x86_64
GNU/Linux
 Build: g++ (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)


Created attachment 22636
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22636
sample program

Linux seymour.toyon.corp 2.6.35.6-48.fc14.x86_64 #1 SMP Fri Oct 22 15:36:08 UTC
2010 x86_64 x86_64 x86_64 GNU/Linux

g++ (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)

Compile the attached source with "g++ test.cpp -O3" and the executable will
report 0<=8<=7.

To make the strange result go away:

- comment out the do-nothing line gValue = EdgeType (or make a number of other
minor changes)

- compile with -O1


[Bug c++/46806] -O3 implies 0 <= 8 <= 7

2010-12-04 Thread cstankevitz at toyon dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46806

--- Comment #2 from Chris Stankevitz  2010-12-05 
02:47:51 UTC ---
> 8 is out of range of the enum.

I agree.  Unfortunately, with -O3, 8 is reported as in the range.


[Bug c++/46806] -O3 implies 0 <= 8 <= 7

2010-12-04 Thread cstankevitz at toyon dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46806

Chris Stankevitz  changed:

   What|Removed |Added

  Attachment #22636|0   |1
is obsolete||

--- Comment #3 from Chris Stankevitz  2010-12-05 
02:53:17 UTC ---
Created attachment 22637
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22637
sample program

Updated sample to use a cast to explicitly compare signed ints.


[Bug c++/46806] -O3 implies 0 <= 8 <= 7

2010-12-05 Thread cstankevitz at toyon dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46806

--- Comment #7 from Chris Stankevitz  2010-12-05 
18:11:55 UTC ---

If I understand correctly, you are saying "The following is not a valid way to
test whether a user-supplied int is withing the bounds of an enum:"

  if (
Eight >= static_cast(eZero) &&
Eight <= static_cast(eSeven))
  {
Value = static_cast(Eight);

std::cerr << "0 <= 8 <= 7 (this is bad)\n";
  }

What is the correct, valid, portable way to test whether a user-supplied int is
in the range of an enum?

Thank you,

Chris


[Bug c++/46806] -O3 implies 0 <= 8 <= 7

2010-12-05 Thread cstankevitz at toyon dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46806

Chris Stankevitz  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution||INVALID

--- Comment #10 from Chris Stankevitz  2010-12-05 
23:47:19 UTC ---
> The comparisons are ok, with or without casts, I think the problem
> is this line:
> Value = static_cast(Eight);

I disagree because the problem exists even if that line is this more reasonable
statement:

  Value = static_cast(eZero);