If I pass a negative number as argument to sqrt() it returns a NAN as
expected. Is there any way to debug this problem using GDB
Let me know
Co 10 7115
Codas obfuscatus wrote: If I pass a negative number as argument to sqrt() it returns a NAN as expected. Is there any way to debug this problem using GDB Let me know Co
If it's doing what you expected, I don't see a problem (but note that
the result of such a domain error is implementation-defined, and not
necessarily portable).
Specific tools (such as gdb) are off-topic here. This group discusses
the C language, not tools.
-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Codas obfuscatus wrote: If I pass a negative number as argument to sqrt() it returns a NAN as expected. Is there any way to debug this problem using GDB Let me know
If you are trying to discover what function passes
the negative argument to sqrt(), one C-only approach
would be to "wrap" the sqrt() call with your own function:
#include <stdio.h>
#include <math.h>
double my_sqrt(double x, const char *file, int line) {
if (x < 0.0)
fprintf (stderr, "sqrt(%g) called from %s, line %d\n",
x, file, line);
return sqrt(x);
}
Then in each file that calls sqrt(), you would insert
something like this *after* the #include <math.h>:
#include <math.h>
...
double my_sqrt(double, const char*, int);
#undef sqrt /* in case <math.h> defines it as a macro */
#define sqrt(x) my_sqrt((x), __FILE__, __LINE__)
These "intercepti ng" lines could, of course, reside in
your own "my_sqrt.h" header file if that's convenient.
-- Er*********@sun .com
Eric Sosman wrote: Codas obfuscatus wrote:
If I pass a negative number as argument to sqrt(), it returns a NAN as expected. Is there any way to debug this problem using GDB? Let me know.
If you are trying to discover what function passes the negative argument to sqrt(), one C-only approach would be to "wrap" the sqrt() call with your own function:
#include <stdio.h> #include <math.h> double my_sqrt(double x, const char *file, int line) { if (x < 0.0) fprintf (stderr, "sqrt(%g) called from %s, line %d\n", x, file, line); return sqrt(x); }
Then in each file that calls sqrt(), you would insert something like this *after* the #include <math.h>:
#include <math.h> ... double my_sqrt(double, const char*, int); #undef sqrt /* in case <math.h> defines it as a macro */ #define sqrt(x) my_sqrt((x), __FILE__, __LINE__)
These "intercepti ng" lines could, of course, reside in your own "my_sqrt.h" header file if that's convenient.
That's a *great* idea!
Where did you get it? ;-)
Eric Sosman <Er*********@su n.com> wrote in message news:<3F******* ********@sun.co m>...
<snip> #include <math.h> ... double my_sqrt(double, const char*, int); #undef sqrt /* in case <math.h> defines it as a macro */ #define sqrt(x) my_sqrt((x), __FILE__, __LINE__)
^^^
Why parenthesise x here?
--
Peter ai***@acay.com. au (Peter Nilsson) writes: Eric Sosman <Er*********@su n.com> wrote in message news:<3F******* ********@sun.co m>...
<snip> #include <math.h> ... double my_sqrt(double, const char*, int); #undef sqrt /* in case <math.h> defines it as a macro */ #define sqrt(x) my_sqrt((x), __FILE__, __LINE__)
^^^ Why parenthesise x here?
Because all macro arguments should be fully parenthesized to avoid
operator precedence problems. (This assumes that the macro is
supposed to act like a function call and the arguments are supposed to
be expressions.)
In this particular case, the argument to the sqrt() macro is already
enclosed in parentheses, so there may not be any actual argument that
would be legal for a call to the sqrt() function that would cause
problems for the sqrt() macro. I've tried and failed to come up with
a problematic example using the comma operator. But it's much easier
to add the parentheses than to prove that they're unnecessary in this
particular case.
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Keith Thompson wrote: ai***@acay.com. au (Peter Nilsson) writes: Eric Sosman <Er*********@su n.com> wrote in message
<snip> #include <math.h> ... double my_sqrt(double, const char*, int); #undef sqrt /* in case <math.h> defines it as a macro */ #define sqrt(x) my_sqrt((x), __FILE__, __LINE__)
^^^ Why parenthesise x here?
Because all macro arguments should be fully parenthesized to avoid operator precedence problems. (This assumes that the macro is supposed to act like a function call and the arguments are supposed to be expressions.)
In this particular case, the argument to the sqrt() macro is already enclosed in parentheses, so there may not be any actual argument that would be legal for a call to the sqrt() function that would cause problems for the sqrt() macro. I've tried and failed to come up with a problematic example using the comma operator. But it's much easier to add the parentheses than to prove that they're unnecessary in this particular case.
Won't "foo = sqrt(2, 4);" foul up without the parens? It should
barf at compile time.
--
Chuck F (cb********@yah oo.com) (cb********@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!
CBFalconer wrote: #define sqrt(x) my_sqrt((x), __FILE__, __LINE__)
^^^ Why parenthesise x here?
Won't "foo = sqrt(2, 4);" foul up without the parens? It should barf at compile time.
Won't it foul up either way? The comma in that context should act as an
argument separator, not the comma operator, shouldn't it?
-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
CBFalconer <cb********@yah oo.com> writes: Keith Thompson wrote: ai***@acay.com. au (Peter Nilsson) writes: Eric Sosman <Er*********@su n.com> wrote in message
<snip> > > #include <math.h> > ... > double my_sqrt(double, const char*, int); > #undef sqrt /* in case <math.h> defines it as a macro */ > #define sqrt(x) my_sqrt((x), __FILE__, __LINE__) ^^^ Why parenthesise x here?
Because all macro arguments should be fully parenthesized to avoid operator precedence problems. (This assumes that the macro is supposed to act like a function call and the arguments are supposed to be expressions.)
In this particular case, the argument to the sqrt() macro is already enclosed in parentheses, so there may not be any actual argument that would be legal for a call to the sqrt() function that would cause problems for the sqrt() macro. I've tried and failed to come up with a problematic example using the comma operator. But it's much easier to add the parentheses than to prove that they're unnecessary in this particular case.
Won't "foo = sqrt(2, 4);" foul up without the parens? It should barf at compile time.
That's basically the example I was trying to come up with, but
"foo = sqrt(2, 4);" would foul up whether sqrt() is a macro or a
function taking one argument. The resulting error message might be
confusing, though.
If you want to pass an expression with a comma operator as a function
argument, you have to parenthesize it: "foo = sqrt((2, 4));" -- which
also avoids the problem.
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Peter Nilsson wrote: Eric Sosman <Er*********@su n.com> wrote in message news:<3F******* ********@sun.co m>...
<snip> #include <math.h> ... double my_sqrt(double, const char*, int); #undef sqrt /* in case <math.h> defines it as a macro */ #define sqrt(x) my_sqrt((x), __FILE__, __LINE__)
^^^ Why parenthesise x here?
Because (good habits) are (hard (to break))?
-- Er*********@sun .com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bob Bamberg |
last post by:
Hello All,
I have been trying without luck to get some information on debugging
the Runtime Error R6025 - Pure Virtual Function Call. I am working in
C++ and have only one class that is derived from an Abstract class, I
do not believe that this class object is causing me my problem. Below
is that message I have posted before to other...
|
by: Brian Conway |
last post by:
I have no idea what is going on. I have a Login screen where someone types
in their login information and this populates a datagrid based off of the
login. Works great in debug and test through VS, however, when I change to
release and put it out on the web it fails giving me the following error
message
The underlying connection was...
|
by: Stephen Miller |
last post by:
Hi,
I am running v1.1.4322 on Win2K server and unable to debug a ASP.Net
application running locally, using a full URL (ie www.mysite.com).
When I hit F5, I get the following error message:
<debugger_error_message>
Error while trying to run project: Unable to start debugging on the
web server.
The project is not configured to be...
|
by: Don Hans |
last post by:
Gents,
Have .Net2003 Enterprise architect installed on a Win2k Server with IIS.
Even logged in as administrator, I cannot run any ASP.NET app with
debugging. I always get the error "Unable to start debugger on the web
server: Access is Denied" when attempting to start the app with debugging.
Now, I have already spent 3 days going...
|
by: Matt |
last post by:
When I try to run the ASP.NET application, it has the following error
messages:
Error while trying to run project: unable to start debugging on the web
server. The project
is not configured to be debugged
| |
by: Bruce Schechter |
last post by:
I just started to develop an ASP.NET application in vs.net 2003 . But each
time I try to execute the application (which is basically empty so far), I
get a dialog box titled "Microsoft Development Environment" with this
message:
"Error while trying to run project: Unable to start debugging on the web
server. Server-side error occurred on...
|
by: Shawn |
last post by:
JIT Debugging failed with the following error: Access is denied.
JIT Debugging was initiated by the following account 'PLISKEN\ASPNET'
I get this messag in a dialog window when I try to open an asp.net page. If
I press OK then I get a page with this message:
Server Application Unavailable
The web application you are attempting to access...
|
by: snicks |
last post by:
I'm trying to exec a program external to my ASP.NET app using the following
code. The external app is a VB.NET application.
Dim sPPTOut As String
sPPTOut = MDEPDirStr + sID + ".ppt"
Dim p As New System.Diagnostics.Process
'p.Start(MDEPDirStr & "macrun.exe", sPPTOut)
p.Start("C:\WINDOWS\SYSTEM32\CALC.EXE")...
|
by: Benny |
last post by:
I have been trying to instal AutoCAD 2008 on a single PC and get the
following
Microsoft .NET Framework security error.
I have updated to the latest .NET Framework 2.0 software, however, this
error occurred with only v1.1 installed.
I also got the same error when trying to install an old ACAD 2005 version
(as
a check). I have successfully...
|
by: John [H2O] |
last post by:
There's a lot of greek for me here ... should I post to numpy-discussions as
well???
The backtrace is at the bottom.... Thanks!
GNU gdb Fedora (6.8-21.fc9)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |