Tuesday, April 4, 2017

Digest for comp.lang.c++@googlegroups.com - 18 updates in 8 topics

Andrey Karpov <karpov2007@gmail.com>: Apr 04 12:43AM -0700

In May 2016, German game-development company Crytek made the, decision to upload the source code of their game engine, 'CryEngine V' to GitHub. The project is in active development, which leads to a large number of errors in the code. We have already checked the project with PVS-Studio for Windows, and now we can also analyze it using PVS-Studio for Linux. There was enough material for an article with the description of only crucial errors.
 
Article: https://www.viva64.com/en/b/0495/
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Apr 04 07:07AM -0700

"Critical errors"
 
#1 It's code for a video game engine, not a life support system.
 
#2 Does the game run? A critical error would prevent it from running.
A bug would prevent it from running corre in certain cases.
 
#3 How much money do you expect to make off this post on comp.lang.c++ ?
And how much knowledge do you hope to impart to people, to increase their
developer skills?
 
Thank you,
Rick C. Hodgin
"Chris M. Thomasson" <invalid@invalid.invalid>: Apr 04 03:24PM -0700

On 4/4/2017 7:07 AM, Rick C. Hodgin wrote:
 
> #1 It's code for a video game engine, not a life support system.
 
> #2 Does the game run? A critical error would prevent it from running.
> A bug would prevent it from running corre in certain cases.
 
Heck, what about this approximation for sqrt in a game:
 
http://forums.parallax.com/discussion/147522/dog-leg-hypotenuse-approximation
 
Better than using a real sqrt function! ;^)
 
 
 
Jorgen Grahn <grahn+nntp@snipabacken.se>: Apr 04 06:14PM

On Thu, 2017-03-23, bitrex wrote:
 
> Got it. I've been using Code::Blocks on Linux, the current version comes
> with Valgrind already plugged-in, are there any recommended profiling
> tools for that setup?
 
If you need tools to detect that your code isn't fast enough, chances are
that it /is/ fast enough, after all ;-)
 
I got the impression from your first posting that performance wasn't
your focus. And IMHO, it shouldn't be.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
Robert Wessel <robertwessel2@yahoo.com>: Apr 04 04:43PM -0500

On 4 Apr 2017 18:14:00 GMT, Jorgen Grahn <grahn+nntp@snipabacken.se>
wrote:
 
>> tools for that setup?
 
>If you need tools to detect that your code isn't fast enough, chances are
>that it /is/ fast enough, after all ;-)
 
 
That's not really fair. Using a profiler, or some other tool, to
measure where the bottlenecks in your program are is an excellent way
to proceed once you've determined that the code is, in fact, too
slow. While it would normally be silly to use a profiler to *detect*
bad performance, using one to *locate* it is a much better idea that
the near-random guessing technique preferred by most programmers.
ram@zedat.fu-berlin.de (Stefan Ram): Apr 04 04:27AM

>Is it possible to modify the following code such that class "Bar"
>contains a const array of "Foo" with a template size, and a stack
>holding *consts into that array? That is to say something like:
 
When const memory, which might be in ROM, is being const-casted
to non-const, this can lead to problems.
 
But I think it might be less grave to cast non-const memory to
const. So what about initializing the memory and then const-casting
it to const? (Actually one would cast a pointer or some such.)
 
(I also thought about using placement new to place const objects,
but it would end up having an effect similar to a const-cast.)
ram@zedat.fu-berlin.de (Stefan Ram): Apr 04 06:41PM

>pointers; the STL seemed to balk at something like std::stack<MyType
>*const>, though I can't remember the exact error and don't have a
>compiler handy.
 
An
 
int const *
 
is the type of a non-const pointer to a const int object,
while an
 
int * const
 
is the type of a const pointer to a non-const int object.
 
Some STL containers (at least ::std::vector and probably
also ::std::stack) require their components to be
copy assignable. So the problem is not with the syntax,
but with the container requirements.
 
The syntax is ok, for example, when it is used with
::std::array. - There is no error reported here for
 
#include <array>
#include <initializer_list>
 
int main()
{ int i = 2;
int * const p = &i;
::std::array< int * const, 2 > s{ { p, &i }}; }
 
.
Juha Nieminen <nospam@thanks.invalid>: Apr 04 06:08AM

In comp.lang.c++ Jeff-Relf.Me wrote:
>> Even when you fix the macro, there's still the problem of calling it
>> like isLeapYear(someReallyExpensiveFunctionThatTakesAMinuteToReturn()).
 
> Thanks for dreaming up scary scenarios however,
 
Dreaming up scary scenarios... Something like isLeapYear(a+b) is not
a stretch in any way. It's something that anybody would write. And your
macro would give the wrong answer.
chrisv <chrisv@nospam.invalid>: Apr 04 07:23AM -0500

Juha Nieminen wrote:
 
>In comp.lang.c++ Jeff-Relf.Me wrote:
 
*plonk*
Jerry Stuckle <jstucklex@attglobal.net>: Apr 04 09:06AM -0400

On 4/4/2017 2:08 AM, Juha Nieminen wrote:
 
> Dreaming up scary scenarios... Something like isLeapYear(a+b) is not
> a stretch in any way. It's something that anybody would write. And your
> macro would give the wrong answer.
 
And it is easily fixed by coding the macro correctly:
 
#define isLeapYear(y) ( !( (y)%400 ) || (y)%100 && !( (y)%4 ) )
 
You can code incorrectly in *any* language.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Jerry Stuckle <jstucklex@attglobal.net>: Apr 04 09:08AM -0400

On 4/4/2017 9:06 AM, Jerry Stuckle wrote:
 
> And it is easily fixed by coding the macro correctly:
 
> #define isLeapYear(y) ( !( (y)%400 ) || (y)%100 && !( (y)%4 ) )
 
> You can code incorrectly in *any* language.
 
(too fast on the send button)
 
That still doesn't solve the problem of isLeapYear(j++). But it doesn't
make macros any more or less evil than other statements.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Silver-Tongued Heel <sl@im.er>: Apr 04 12:43PM -0400

On 2017-04-04 8:23 AM, chrisv wrote:
> Juha Nieminen wrote:
 
>> In comp.lang.c++ Jeff-Relf.Me wrote:
 
> *plonk*
 
LOL.
 
 
--
Silver Tongued-Heel
OpenMedia & EFF Member
Gab.ai: @silverslimer
Jeff-Relf.Me @.: Apr 04 10:47AM -0700

Jerry Stuckle <jstucklex@attglobal.net>: Apr 04 02:08PM -0400

> Jerry Stuckle, Juha Nieminen, Mr. DFS... this would be be better:
 
> inline int isLeapYear( int y ) { return !( y%400 ) || y%100 && !( y%4 ); }
 
> You know it's inlined when you can't set a break point on it.
 
That isn't a macro.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Bonita Montero <Bonita.Montero@gmail.com>: Apr 04 07:53PM +0200

You don't even understand condition-variables.
 
--
http://facebook.com/bonita.montero/
bitrex <bitrex@de.lete.earthlink.net>: Apr 04 12:38PM -0400

On 04/04/2017 12:27 AM, Stefan Ram wrote:
> it to const? (Actually one would cast a pointer or some such.)
 
> (I also thought about using placement new to place const objects,
> but it would end up having an effect similar to a const-cast.)
 
Sure, I think that would be OK. Essentially I'd like to have an array of
X number of objects (template parameter) in a container class
instantiated when the container is instantiated (or maybe static), and
then have access to pointers to those objects through a stack data
structure. The const qualification of the pointers on the stack would
enforce that "these are all the objects you get to play with, here, you
can't pull one of these pointers off the stack by non-const reference
and point it at something else."
 
I had some trouble with the syntax for a stack of const-qualified
pointers; the STL seemed to balk at something like std::stack<MyType
*const>, though I can't remember the exact error and don't have a
compiler handy.
aminer68@gmail.com: Apr 04 07:54AM -0700

Hello,
 
 
My C++ MemPool for real-time systems was updated to version 1.06
 
 
Description:
 
Real-Time Memory Management
 
In C++, memory management is normally performed using new,delete etc. The run-time system's heap offers great flexibility and efficiency, but it cannot fulfil real-time requirements. The run-time requirements are non-deterministic. In addition, they may require blocking task switches, which makes them unusable for interrupt handlers.
 
MemPool uses templates and offers memory management with real-time capabilities through Memory Pools. A Memory Pool is an isolated heap with data buffers as objects of equal size. Any number of memory pools can exist simultaneously. A pool is initialized once and allocated a certain number of buffers as objects. Thereafter, buffers as objects can be allocated and deallocated from the pool under real-time conditions.
 
How to use it?
 
The parameters of the constructor are:
 
The first parameter is the number of items and the second parameter is a boolean parameter that will tell MemPool to grow or not, if it is set to true it will grow, set it to false for real-time systems, if you don't pass any parameter, the number of items will be set to 200 and the MemPool will not grow and thus it will be set for real-time systems.
 
The New() method returns a reference to the object, it's in O(1) time complexity.
 
The Return() method returns the reference to the object to the stack, it 's in O(1) time complexity.
 
Please look at the test.cpp example to learn how to use MemPool.
 
Language: GNU C++ and Visual C++ and C++Builder
 
 
You can download it from:
 
https://sites.google.com/site/aminer68/c-mempool-for-real-time-systems
 
 
 
Thank you,
Amine Moulay Ramdane.
Ramine <toto1@toto1.net>: Apr 04 10:51AM -0400

Hello,
 
 
Efficient C++ Bounded Thread-Safe FIFO Queue and LIFO Stack for
real-time systems.
 
 
Description:
 
Efficient C++ Bounded Thread-Safe FIFO Queue and LIFO Stack for
real-time systems, they are efficient and they eliminate false-sharing
and they are FIFO fair and starvation-free.
 
Language: GNU C++ and Visual C++ and C++Builder
 
 
You can download it from here:
 
https://sites.google.com/site/aminer68/efficient-c-bounded-thread-safe-fifo-queue-and-lifo-stack-for-real-time-systems
 
 
 
Thank you,
Amine Moulay Ramdane.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: