is assert() for debug only or not?
Is it possible that I have seen the use of assert() in the Borland
c++ 32 compiler (so assert is not for debug only)? 21 7277
Giuseppe <gi******@giuse ppe.wwwew> wrote: is assert() for debug only or not?
Yes. Or let it state in another way. Assert should only be used while
the code is in development, than when you release your product/program,
you want to compile with NODEBUG defined, so that all assertions will be
gone.
Is it possible that I have seen the use of assert() in the Borland c++ 32 compiler (so assert is not for debug only)?
It is possible, though one cannot conclude from that fact that this is
the correct usage anyway. Borland seams to have released a debug-version
or their product.
--
Z (Zo**********@d aimlerchrysler. com)
"LISP is worth learning for the profound enlightenment experience
you will have when you finally get it; that experience will make you
a better programmer for the rest of your days." -- Eric S. Raymond
>is assert() for debug only or not?
The purpose of a tool is determined by the person using it. It is
possible that someone out there uses assert() for driving nails and
uses pencils for murdering people. Is it possible that I have seen the use of assert() in the Borland c++ 32 compiler (so assert is not for debug only)?
Is it possible that you have seen the source code of the Borland
c++ 32 compiler? I don't know. If you have, whether or not it
uses assert() says little about whether or not assert() is for debug
only. Just because code is a production release does not mean it
is bug-free. However, I'm not sure I'd be comfortable riding in
an airplane or spacecraft whose flight-control software used assert(),
or living near a nuclear reactor whose control software used it.
Gordon L. Burditt gi******@giusep pe.wwwew (Giuseppe) wrote:
# is assert() for debug only or not?
# Is it possible that I have seen the use of assert() in the Borland
# c++ 32 compiler (so assert is not for debug only)?
The most diffult to debug, to understand problems occur in once the code
is in production, where it is constantly hammerred to its limits by people
who have no respect for your test suite.
Therefore in the interest of speed, production code is precisely when
you need to disable all checking, assertions, array bounds and other
ranges, stacks popped properly, etc. This ensures the maximum damage and
the least possibility of fixing it.
--
Derk Gwen http://derkgwen.250free.com/html/index.html
So....that would make Bethany part black? gi******@giusep pe.wwwew (Giuseppe) wrote in message news:<3f******* *******@news.ti n.it>... is assert() for debug only or not? Is it possible that I have seen the use of assert() in the Borland c++ 32 compiler (so assert is not for debug only)?
as you may have gathered there are some differences of
opinion on this one. Try googling comp.lang.c for "assert".
For instance I've posted some particularly good things on
assert :-)
(google for my surname, you're unlikely to get false positives
in comp.lang.c).
--
Nick Keighley
"Derk Gwen" <de******@HotPO P.com> wrote in message The most diffult to debug, to understand problems occur in once the code is in production, where it is constantly hammerred to its limits by people who have no respect for your test suite.
It depends what your product is. If you release a game, and it assert fails,
a savvy player will know that there must be a design bug. However it is
unlikely that your studio is set up to release patches and maintenance
versions, so you end up in an awkward position.
Far better to just crash.
Zoran Cutura wrote: Giuseppe wrote:
Is assert() for debug only or not?
Yes. Or let it state in another way. Assert should only be used while the code is in development, then when you release your product/program, you want to compile with NODEBUG defined, so that all assertions will be gone.
For amateur programmers (programmers who write code for their own use),
there is no clear distinction between
the program development phase and the program deployment phase.
They try to use their code with no formal testing
as soon as they can get it to compile without any errors.
They are always modifying and debugging their code
until they are finished using it -- then they throw it away.
For amateur programmers, it is usually sufficient
to simply exit from a program when an exception is encountered.
For professional programmers, it is almost always necessary
to include code to detect and handle the exception for users
because the users may not be programmers themselves.
The C preprocessor assert macro is almost never
the best way to detect and handle exceptions so it is not used
for exception handling by professional programmers.
Zoran Cutura wrote: Giuseppe <gi******@giuse ppe.wwwew> wrote: is assert() for debug only or not?
Yes. Or let it state in another way. Assert should only be used while the code is in development, than when you release your product/program, you want to compile with NODEBUG defined, so that all assertions will be gone.
You meant: NDEBUG
<snip>
--
Richard Heathfield : bi****@eton.pow ernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Malcolm wrote: "Derk Gwen" <de******@HotPO P.com> wrote in message The most diffult to debug, to understand problems occur in once the code is in production, where it is constantly hammerred to its limits by people who have no respect for your test suite.
It depends what your product is. If you release a game, and it assert fails, a savvy player will know that there must be a design bug. However it is unlikely that your studio is set up to release patches and maintenance versions, so you end up in an awkward position. Far better to just crash.
The "savvy player" whose game crashes will not be keen to buy games from the
same company again.
Far better not to do things that might make the game crash.
--
Richard Heathfield : bi****@eton.pow ernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Derk Gwen wrote: gi******@giusep pe.wwwew (Giuseppe) wrote: # is assert() for debug only or not? # Is it possible that I have seen the use of assert() in the Borland # c++ 32 compiler (so assert is not for debug only)?
The most diffult to debug, to understand problems occur in once the code is in production, where it is constantly hammerred to its limits by people who have no respect for your test suite.
Therefore in the interest of speed, production code is precisely when you need to disable all checking, assertions, array bounds and other ranges, stacks popped properly, etc. This ensures the maximum damage and the least possibility of fixing it.
If you're not 100% sure that the program can run correctly without the
assertions, your program is not ready for production.
--
Richard Heathfield : bi****@eton.pow ernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Fábio Mendes |
last post by:
I'm sorry if it's an replicate. Either my e-mail program is messing with
things or the python-list sent my msg to /dev/null. I couldn't find
anything related in previous PEP's, so here it goes a very early draft
for a new "assert" syntax:
This was inspired in Ruby's assert syntax. I'm not familiar with Ruby at
all, so the chances are that this piece of code is broken, but I think
the idea is very obvious. In Ruby, assert is simply a...
|
by: Thomas Guettler |
last post by:
Hi,
Python 2.3.3 (#1, Feb 5 2005, 16:22:10) on linux2
>>> assert 0, "foo"
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AssertionError: foo
>>> assert(0, "foo")
>>>
|
by: Daniel Vallstrom |
last post by:
I'm having problems with inconsistent floating point behavior
resulting in e.g.
assert( x > 0.0 && putchar('\n') && x == 0.0 );
holding. (Actually, my problem is the dual one where I get
failed assertions for assertions that at first thought ought
to hold, but that's not important.)
At the end is a full program containing the above seemingly
|
by: Alex Vinokur |
last post by:
Here are two programs.
--- foo1.c ---
#include <assert.h>
#define FOO 10
int main()
{
assert (15 < FOO);
return 0;
}
|
by: Rob Thorpe |
last post by:
In general, is it considered bad practice to use asserts in production
code?
What about writing a macro that does the same as assert but continues
to work regardless of the state of NDEBUG?
I can see that it would be poor style to use it for commonly
encountered errors, but what about truly exceptional errors that would
rarely if ever be encountered?
| |
by: lovecreatesbeauty |
last post by:
Besides printing out for example
" a.out: p113.c:8: main: Assertion `0' failed.
Aborted "
and a switch option NDEBUG, what other benefits does assert() provide
in any scope of designing, debugging/coding and/or testing?
Do you prefer the if statement of the language to the assert MACRO of
the precompiler?
|
by: priyanka |
last post by:
Hi there,
Can anyone show me how the assert() function works ? I need to develop
my own assert() function instead of using the one defined in the
assert.h file. It would be great if anyone could show me the actual
source code of assert() function in assert.h header file.
I need to write the assert function that prints out error message when
the expression is wrong. For eg.,
|
by: =?Utf-8?B?R2Vvcmdl?= |
last post by:
Hello everyone,
I saw a couple of form of assert in code on Windows,
1. ASSERT;
2. assert;
3. _ASSERT;
4. _assert.
|
by: Tomás Ó hÉilidhe |
last post by:
In C89, do we have to pass an int as an argument to assert? I've got code
at the moment that does an assertion on pointer, e.g.:
assert(p);
, but I'm wondering if I should change that to:
assert(0 != p);
|
by: pereges |
last post by:
Ok, so once I'm done debugging my code(split across multiple modules)
using the assert macro, I would want to switch off all the assert
macros ued in the program. Does this mean I have to include:
#define NDEBUG
in every .c where I used assert or defining it one file would turn off
all assert macros in every file ?
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
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: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |