Compile with:
g++ crash.cpp -O2
Crashes on:
g++ (Gentoo 4.3.2 p1.1) 4.3.2
g++ (GCC) 4.3.0 20080428 (Red Hat 4.3.0-8)
g++ (ubuntu current stable)
Steps to reproduce:
1. Make a file crash.cpp (contents below)
2. g++ crash.cpp -O2
3. ./a.out
Floating point exception
Source:
#include <iostream>
#include <fenv.h>
float g(const float& x)
{
float y = x;
if(y == 0.0f)
{
y=1.0f;
}
return x/y;
}
void f(const float &z)
{
if (z 0.0f)
{
float Unit2 = g(z);
std::cout << Unit2;
}
}
int main()
{
feenableexcept( FE_INVALID);
float a = 130.0f;
f(a);
return 0;
}
Nov 6 '08
15 1684
[about comparing floating point numbers]
James Kanze wrote:
On Nov 6, 11:22 pm, Salt_Peter <pj_h...@yahoo. comwrote:
>the following is expected...
>#include <iostream>
>int main() { float fa(0.0f); float fb(0.0f);
> if( fa == fb) std::cout << "not equal\n"; else std::cout << "equal\n";
"==": not equal,
"!=": equal?
I'll case that as typing error. ;-)
> std::cout << "Press ENTER to EXIT.\n"; std::cin.get(); }
>/* not equal */
Are you kidding? Any compiler which outputs "not equal" with
that program is seriously broken.
I disagree. Any compiler outputting "equal" with this program is broken.
But trying to prove something with a wrong program is broken, too.
--
Thomas
On 2008-11-07 09:31:43 -0500, "Thomas J. Gritzan"
<ph************ *@gmx.desaid:
[about comparing floating point numbers]
James Kanze wrote:
>On Nov 6, 11:22 pm, Salt_Peter <pj_h...@yahoo. comwrote:
>>the following is expected...
>>#include <iostream>
>>int main() { float fa(0.0f); float fb(0.0f);
>>if( fa == fb) std::cout << "not equal\n"; else std::cout << "equal\n";
"==": not equal,
"!=": equal?
I'll case that as typing error. ;-)
>>std::cout << "Press ENTER to EXIT.\n"; std::cin.get( ); }
>>/* not equal */
Are you kidding? Any compiler which outputs "not equal" with that program is seriously broken.
I disagree. Any compiler outputting "equal" with this program is broken.
Good catch. Fake results.
--
Pete
Roundhouse Consulting, Ltd. ( www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
( www.petebecker.com/tr1book) ch************* @gmail.com wrote:
>
Crashes on:
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 (my machine, but maybe not Rolf's)
I tried it with -O2. No crash with the very same compiler version.
PS: Rolf, sorry for calling you Peter earlier.
No problem. I think I'll live ;-)
On Nov 7, 11:03*am, Rolf Magnus <ramag...@t-online.dewrote:
I tried it with -O2. No crash with the very same compiler version.
Looks like it's a problem with 64 bit only. I also don't have a
problem on 32 bit.
Rolf, are you running 32 or 64 bit?
I filed a bug and it was closed fixed in 4.3.3
Chris
On Nov 8, 12:28*am, chrisstankev... @gmail.com wrote:
On Nov 7, 11:03*am, Rolf Magnus <ramag...@t-online.dewrote:
I tried it with -O2. No crash with the very same compiler
version.
Looks like it's a problem with 64 bit only. *I also don't have
a problem on 32 bit.
Rolf, are you running 32 or 64 bit?
I just tried it in 64 bit with g++ 4.2.1 (under Suse Linux, with
the 2.6.22 kernel). No problems.
--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34 ch************* @gmail.com wrote:
On Nov 7, 11:03 am, Rolf Magnus <ramag...@t-online.dewrote:
>I tried it with -O2. No crash with the very same compiler version.
Looks like it's a problem with 64 bit only. I also don't have a
problem on 32 bit.
Rolf, are you running 32 or 64 bit?
I'm running 32 bit. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Paul |
last post by:
Hi,
Global operator new and delete are overloaded and I am using stl map
to store pointers, but this code crashes, can some one shed some
light???
Compiler: MS VC++ 6.0
STL: Shipped with Visual Studio.
#include <malloc.h>
#include <map>
|
by: Mike Treadway |
last post by:
Here's a posting from someone else that describes my problem. The issue is
happening on two Windows 2000 machines that have Veritas installed. That's
the only obvious common thing I can see between the two machines.
Someone Else:
I am developing a three tiered Windows Service application using remoting.
The Server portion of the program runs on a Windows Server 2k3 machine and
intermittently crashes. The event log contains the...
|
by: Neo The One |
last post by:
I think C# is forcing us to write more code by enforcing a rule that can be
summarized as 'A local variable must be assgined *explicitly* before reading
its value.'
If you are interested in what I mean, please look at this feedback my me:
http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=3074c204-04e4-4383-9dd2-d266472a84ac
If you think I am right, please vote for this feedback.
|
by: Harry Simpson |
last post by:
I've got a call within my .NET code to a function which uses an API call to
get printer settings. When there's an error in the API call code, it
crashes the .NET app. Try Catch doesn't prevent the crash - it's like it
crashes before the catch catches.....
Any ideas how to error handle this type of function so it doesn't crash the
application??
TIA
|
by: Norman Diamond |
last post by:
When Visual Studio 2005 SP1 crashes, sometimes it offers to send a dump to
Microsoft, but sometimes it doesn't. Is there some way to encourage it to
send dumps more often?
One crash resulted in this event in the application event log:
$B%$%Y%s%H$N<oN`(B: $B%(%i!<(B
$B%$%Y%s%H(B $B%=!<%9(B: .NET Runtime
$B%$%Y%s%H(B $B%+%F%4%j(B: $B$J$7(B
$B%$%Y%s%H(B ID: 1023
$BF|IU(B: 2007/07/24
| |
by: Chris Paxton |
last post by:
I have a fairly basic VB.NET application that I converted from VS2003 to
VS2005 and now it crashed the VS2005 IDE pretty regularly while trying to
use the form designer.
I've removed any 3rd references in my projects and recoded methods to remove
any deprecated functions.
Anyone have any suggestions?
|
by: whutto |
last post by:
I have a VB.NET app that crashes when run from the Windows scheduled tasks, but runs fine when the run-as user is logged on. The app also runs fine from the scheduled jobs if the run as user is disconnected. The O/S is Windows Server 2003, the app is created with VB.NET 2003. The .NET framework is up todate with Windows releases. The APP opens connections to an SQL Server 2003 database and an ODBC sql connection to an iSeries database.
...
|
by: Jameson |
last post by:
Visual Studio 2008 (90 day trial, team suite edition) crashes with
"Microsoft Visual Studio 2008 has encountered a problem and needs to
close...." message when I try to create a new wpf application project.
Also, loading an existing wpf project (the "hittest3d" demo) works, but the
program terminates when the system tries to display the test project main
window (ie. step into the program, debugging just stops at new window1()).
Possibly...
|
by: minima producciones |
last post by:
Hello,
The scenario is this: VB.net 2003 connecting to Access 2003 using Jet
4.0 SP8 and MDAC 2.7 SP1.
On a particular client machine with XP SP2, while trying to fill a
dataset it crashes fantastically without ANY error message. the exe
just disappears from the task manager.
I use a Module to launch the MainApp form, if I try to connect within
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |