Saturday, April 30, 2016

Digest for comp.lang.c++@googlegroups.com - 6 updates in 3 topics

Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Apr 30 11:00PM +0100

On Sat, 30 Apr 2016 23:50:06 +0200
> theoretically possible. However, you might find that many compilers
> that have sizeof(long) == 1 and CHAR_BIT == 32, don't support long
> long...
 
You are learning too many lessons from Jerry about bogus straw man
arguments. Leaving aside long long, I agree with you, as you will see if
you re-read my posting about systems where all integer types are 32 bit.
 
C requires long long (if supported) to be 64 bits. So for that, his
test would work, in any case where all integer types are not 64 bit,
and as you say I do not know of any.
Ben Bacarisse <ben.usenet@bsb.me.uk>: Apr 30 11:22PM +0100


> It wouldn't have, but on the 16-bit point he could have just substituted
> long for short and his test would work: C (and C++) require long to be
> 32 bits,
 
C requires long to be at least 32 bits (and I presume C++ is similar).
Some of the TI processors have a 40-bit integer type and if an
implementation used that underlying type for long you'd run into the
other issue with padding bits (where c[0] might correspond to bits that
don't contribute to the value of the long).
 
So what's the best way round these issues? Usually you could justify
simply ignoring such odd cases. But to get the most widely portable
solution I'd advise (a) use unsigned types everywhere; (c) use (as you
suggest) unsigned long; (b) set the value the other way round by setting
the representation; (d) print the resulting value so you can pick up odd
cases like the PDP-11's mixed endian byte order:
 
union {
unsigned long value;
unsigned char bytes[sizeof(unsigned long)];
} u;
for (int i = 0; i < sizeof u.bytes; i++)
u.bytes[i] = i + 1;
printf("ORDER_%lx_ENDIAN\n", u.value);
 
You get a more complicated result, but the code that uses it will, most
likely, just use it to reject all the odd cases. If your code depends
on endianess, you probably did not code it to handle 40-bit integers
with 3 16-bit bytes anyway!
 
The above will still go wrong if unsigned long has padding bits and the
resulting bit pattern turns out to be a trap representation. The other
version also suffers from that problem but this one avoids false
positives caused by padding bits.
 
If you have C99 or C11, there's an argument for using unsigned long long
or even uint_max_t rather than unsigned long.
 
<snip>
--
Ben.
David Brown <david.brown@hesbynett.no>: Apr 30 11:57PM +0200

On 30/04/16 23:36, Chris Vine wrote:
> shell command for the purpose.
 
> His solution was unix specific and (so far as concerns the -D option)
> dependent on a compiler such as gcc or clang which supports it.
 
Yes, I noticed that after my post. It is still system dependent - it's
just an attempt at being smart-ass about generating configuration files
automatically. If you know you have gcc, you can use its macros
directly. If you know you have glibc, you can use #include <endian.h>.
I'm sure posix defines a header somewhere containing endian macros.
When you know the details of the system, it's easy - the challenge was
to have a completely implementation-independent solution.
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Apr 30 11:59PM +0100

On Sat, 30 Apr 2016 23:22:13 +0100
> positives caused by padding bits.
 
> If you have C99 or C11, there's an argument for using unsigned long
> long or even uint_max_t rather than unsigned long.
 
Jerry's code provides a larger test type (short in his case but we are
now supposing long), and an array of char of size sizeof(short) - or
sizeof(long) in our supposed case. Sizes of integers must be multiples
of sizeof(char), so it seems to me to be highly improbable that padding
is an issue.
 
I am not an expert of C11 but it seems to me that C11 probably requires
Jerry's scheme to work (C89 does not, nor does C++). §6.2.6.1/7 of C11
provides that "When a value is stored in a member of an object of union
type, the bytes of the object representation that do not correspond to
that member but do correspond to other members take unspecified
values". In the case in question the array of char and the larger
integer type do have the same number of bytes so there are no
unspecified values. But maybe padding is allowed to alter this, I
don't know. The original defect report for C89 leading to C99 said "To
address the issue about "type punning", attach a new footnote 78a to
the words "named member" in 6.5.2.3#3: 78a If the member used to access
the contents of a union object is not the same as the member last used
to store a value in the object, the appropriate part of the object
representation of the value is reinterpreted as an object
representation in the new type as described in 6.2.6 (a process
sometimes called "type punning"). This might be a trap
representation." I am not sure if C11 still permits a trap
representation in this case (see §6.2.6.1/6). If you say it does in
order to permit padding, I will believe you.
 
If it does, there is unspecified behaviour rather than undefined
behaviour. gcc's specified behaviour is to permit type punning of this
kind via unions, and I suspect the same is true of most other compilers
as it is a very common idiom.
 
Chris
Juha Nieminen <nospam@thanks.invalid>: Apr 30 09:40AM


> void foo(char (&a)[4]) {}
 
> 'a' retains its quality as a reference to an array of char of size 4,
> and it will refuse to compile if passed a char array of any other size.
 
It is actually a very useful feature. It's how eg. std::end() and
range-based for loops for static arrays work. They are sometimes
useful for all kinds of things in templated code.
 
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
"Chris M. Thomasson" <nospam@nospam.no>: Apr 30 12:45AM -0700


> FWIW, some, IMHO, fairly interesting C++ code for Field Based DLA:
 
> https://plus.google.com/101799841244447089430/posts/am5EpMHcmig
 
> https://github.com/ChrisMThomasson/CT_fieldDLA
 
[...]
 
BTW, if you have any questions about the code,
please ask them. I think we can make this
algorithm much more efficient, humm...
 
https://github.com/ChrisMThomasson/CT_fieldDLA/blob/master/cairo_test_penrose/ct_field.hpp
 
The (ct::field::search_hit) function can be
improved, along with (ct::field::calc_point).
These are very important "hot spots" in the
(ct::field::render) function.
 
If you are interested, and think this is off topic,
we can move it to:
 
https://plus.google.com/101799841244447089430/posts/DfjAJbbdLGp
 
However, it is C++ with Cairo and GLM, not that bad
for third part libs...
 
If I confine posts to this thread only, is it okay to post updates here?
 
;^o
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.

Digest for comp.lang.c++@googlegroups.com - 25 updates in 1 topic

Jerry Stuckle <jstucklex@attglobal.net>: Apr 29 08:36PM -0400

On 4/29/2016 3:50 PM, Christian Gollwitzer wrote:
> undefined behaviour. (Though, practically it's doing what it is intened
> to do)
 
> Christian
 
Not at all. The determination is made at compile time, as the
requirements specified. They didn't say HOW it was to be determined.
 
And you obviously don't understand how unions work. Show me where it is
"undefined behavior".
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Jerry Stuckle <jstucklex@attglobal.net>: Apr 29 08:38PM -0400

On 4/29/2016 5:02 PM, Ben Bacarisse wrote:
> the endianess of the machine (i.e. how consecutively addressed bytes
> correspond to value bytes).
 
> <snip>
 
Not at all. You just don't understand how unions work. They are NOT
the same as structures.
 
And if sizeof(short) == 1, then endian is immaterial. But I dare you to
show me a single implementation where sizeof(short) == 1.
 
But if you continue to be pedantic about it, then use int instead of short.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
"Öö Tiib" <ootiib@hot.ee>: Apr 29 07:54PM -0700

On Friday, 29 April 2016 19:23:50 UTC+3, Jerry Stuckle wrote:
 
> No, I have moved no goalposts. My statements have been consistent since
> the start. Just because your limited experience hasn't exposed you to
> other options does not mean they don't exist.
 
You started with patronizing "very experienced" claim that some compilers
use different .o and .a formats. What concretely? That is "demand" and
"not important". Instead you move goalposts to nonsense claim that no
one "is required" to use same .o and .a formats. Who has claimed opposite?
 
> > format specified by ISO/IEC 21320-1:2015. Everybody just wants to.
 
> Now who's moving the goalposts - or at least bringing up another red
> herring?
 
It was just an example how that "are not required to" is nonsense that
no one has argued with.
Jerry Stuckle <jstucklex@attglobal.net>: Apr 29 10:59PM -0400

On 4/29/2016 10:54 PM, Öö Tiib wrote:
> use different .o and .a formats. What concretely? That is "demand" and
> "not important". Instead you move goalposts to nonsense claim that no
> one "is required" to use same .o and .a formats. Who has claimed opposite?
 
Patronizing - IN YOUR OPINION. But you have multiple times proven you
are just a pig someone (not only me) tries to teach to sing. I have
moved NOT goalposts - the only "movement" is in your mind.
 
And multiple people, including you, have claimed all .o files are the
same in Linux.
 
>> herring?
 
> It was just an example how that "are not required to" is nonsense that
> no one has argued with.
 
No, it's just another example of trying to teach a pig to sing. Every
time you are proven wrong, YOU try to move the goalposts. It doesn't work.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
"Öö Tiib" <ootiib@hot.ee>: Apr 29 08:39PM -0700

On Saturday, 30 April 2016 05:59:25 UTC+3, Jerry Stuckle wrote:
> moved NOT goalposts - the only "movement" is in your mind.
 
> And multiple people, including you, have claimed all .o files are the
> same in Linux.
 
I have written nothing about Linux or about files being same. It was you
who claimed that 'ar' is gcc tool and I wrote that it has been Unix
utility for ages.
 
> > no one has argued with.
 
> No, it's just another example of trying to teach a pig to sing. Every
> time you are proven wrong, YOU try to move the goalposts. It doesn't work.
 
Sorry, if I tried to teach you to sing. I know you can only oink back.
Jerry Stuckle <jstucklex@attglobal.net>: Apr 29 11:42PM -0400

On 4/29/2016 11:39 PM, Öö Tiib wrote:
 
> I have written nothing about Linux or about files being same. It was you
> who claimed that 'ar' is gcc tool and I wrote that it has been Unix
> utility for ages.
 
So? That still doesn't mean another toolkit can't have its own version.
 
 
>> No, it's just another example of trying to teach a pig to sing. Every
>> time you are proven wrong, YOU try to move the goalposts. It doesn't work.
 
> Sorry, if I tried to teach you to sing. I know you can only oink back.
 
ROFLMAO! Is that all the better you can do, pig?
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
"Öö Tiib" <ootiib@hot.ee>: Apr 29 08:52PM -0700

On Saturday, 30 April 2016 06:43:02 UTC+3, Jerry Stuckle wrote:
> > who claimed that 'ar' is gcc tool and I wrote that it has been Unix
> > utility for ages.
 
> So? That still doesn't mean another toolkit can't have its own version.
 
And that I also already answered that no one argues that they can't. They
can. Also it is impossible to prove negative that no one does use that
liberty. However you argue that they do. So it is up to you to prove
that.
 
> >> time you are proven wrong, YOU try to move the goalposts. It doesn't work.
 
> > Sorry, if I tried to teach you to sing. I know you can only oink back.
 
> ROFLMAO! Is that all the better you can do, pig?
 
Oh yes I forgot that you can also roll on the floor oinking your ass off. :D
Jerry Stuckle <jstucklex@attglobal.net>: Apr 29 11:58PM -0400

On 4/29/2016 11:52 PM, Öö Tiib wrote:
> can. Also it is impossible to prove negative that no one does use that
> liberty. However you argue that they do. So it is up to you to prove
> that.
 
You don't read very well either, do you?
 
 
>>> Sorry, if I tried to teach you to sing. I know you can only oink back.
 
>> ROFLMAO! Is that all the better you can do, pig?
 
> Oh yes I forgot that you can also roll on the floor oinking your ass off. :D
 
Ah, yes. Sorry about that. I shouldn't insult pigs like I did. They
are much better than you - as you have so astutely pointed out.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Paavo Helde <myfirstname@osa.pri.ee>: Apr 30 09:46AM +0300

On 30.04.2016 3:38, Jerry Stuckle wrote:
 
> And if sizeof(short) == 1, then endian is immaterial. But I dare you to
> show me a single implementation where sizeof(short) == 1.
 
Most DSP-s, e.g.:
 
Analog Devices 32-bit SHARC DSP (all integer types are 32 bits)
 
http://www.verycomputer.com/45_793d80b65c0ca44f_1.htm
 
Texas Instruments TMS32F28xx DSP (all integer types are 16 bits)
 
"http://www.thecodingforums.com/threads/implementations-with-char_bit-32.440062/#post-2435265"
Jerry Stuckle <jstucklex@attglobal.net>: Apr 30 08:40AM -0400

On 4/30/2016 2:46 AM, Paavo Helde wrote:
 
> Texas Instruments TMS32F28xx DSP (all integer types are 16 bits)
 
> "http://www.thecodingforums.com/threads/implementations-with-char_bit-32.440062/#post-2435265"
 
How does a 16 bit or 32 bit integer line up with a short size of 1 byte
(8 bits)?
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
"Öö Tiib" <ootiib@hot.ee>: Apr 30 06:57AM -0700

On Saturday, 30 April 2016 15:40:35 UTC+3, Jerry Stuckle wrote:
 
> > "http://www.thecodingforums.com/threads/implementations-with-char_bit-32.440062/#post-2435265"
 
> How does a 16 bit or 32 bit integer line up with a short size of 1 byte
> (8 bits)?
 
Read the links?
"Öö Tiib" <ootiib@hot.ee>: Apr 30 07:01AM -0700

On Saturday, 30 April 2016 06:59:03 UTC+3, Jerry Stuckle wrote:
> > liberty. However you argue that they do. So it is up to you to prove
> > that.
 
> You don't read very well either, do you?
 
Posting only cheap insults? That indicates you can have nothing else left.
Sorry.
 
Jerry Stuckle <jstucklex@attglobal.net>: Apr 30 10:49AM -0400

On 4/30/2016 10:01 AM, Öö Tiib wrote:
 
>> You don't read very well either, do you?
 
> Posting only cheap insults? That indicates you can have nothing else left.
> Sorry.
 
The truth hurts, doesn't it?
 
But I'm through here - you can have the last word. Trolls like you need it.
 
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Jerry Stuckle <jstucklex@attglobal.net>: Apr 30 10:50AM -0400

On 4/30/2016 9:57 AM, Öö Tiib wrote:
 
>> How does a 16 bit or 32 bit integer line up with a short size of 1 byte
>> (8 bits)?
 
> Read the links?
 
Once again you don't read very well, do you? And you obviously don't
understand even the simplest code.
 
But then trolls are like that.
 
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Apr 30 05:05PM +0100

On Sat, 30 Apr 2016 08:40:24 -0400
 
> > "http://www.thecodingforums.com/threads/implementations-with-char_bit-32.440062/#post-2435265"
 
> How does a 16 bit or 32 bit integer line up with a short size of 1
> byte (8 bits)?
 
The sizeof operator references the size of char, not the size of an
octet (8 bits). sizeof(char) is required to evaluate to 1 in both the
C and C++ standards.
 
In the 32 bit case cited, all integer types (char, short, int and long)
appear to be comprised of 32 bits. As your test requires sizeof(char)
to be less than sizeof(short), it does not work for that case. But it
is still quite a neat way of doing it and will work with the vast
majority of systems. You ought to put a -std=c99 or -std=c11 compiler
flag in though, as reading a different union member than the one last
stored gives undefined behaviour with C89 (but not C99/C11).
"Öö Tiib" <ootiib@hot.ee>: Apr 30 09:50AM -0700

On Saturday, 30 April 2016 17:50:57 UTC+3, Jerry Stuckle wrote:
 
> Once again you don't read very well, do you? And you obviously don't
> understand even the simplest code.
 
> But then trolls are like that.
 
Obviously you lie that you can't read at all. You *did* read the links
and *saw* that you are *wrong* again. Therefore you can again only
write pathetic cheap insults. It is becoming uninteresting to bust
your smart aleck bubbles in a row.
Ben Bacarisse <ben.usenet@bsb.me.uk>: Apr 30 08:12PM +0100


>> <snip>
 
> Not at all. You just don't understand how unions work. They are NOT
> the same as structures.
 
Unless you address the issue of padding bits in integer types I'll have
to assume you don't know what the problem is. It is only by
understanding both padding bits *and* unions that you will be able to
see how the code can go wrong.
 
> And if sizeof(short) == 1, then endian is immaterial. But I dare you to
> show me a single implementation where sizeof(short) == 1.
 
You've had some links already but here is another:
 
http://focus.ti.com/lit/ug/spru281f/spru281f.pdf
 
The C compiler for the TMS320C55x has sizeof(short) == 1, but it also
has an integer type with a size > 1. (It also has integer types with
padding bits, as it happens.)
 
> But if you continue to be pedantic about it, then use int instead of
> short.
 
sizeof(int) == 1 for the compiler I have just cited.
 
--
Ben.
David Brown <david.brown@hesbynett.no>: Apr 30 09:21PM +0200

On 29/04/16 20:28, Jerry Stuckle wrote:
> printf("BIGENDIAN");
> return 0;
> }
 
That is runtime only - it does not generate a constant expression. And
it is not portable to systems where sizeof(short) == 1.
 
>

Friday, April 29, 2016

Digest for comp.lang.c++@googlegroups.com - 20 updates in 6 topics

red floyd <no.spam.here@its.invalid>: Apr 19 10:38PM -0700

On 4/19/2016 7:09 AM, Scott Lurndal wrote:
> and useful addressing modes.
 
>> they were on the inside. Possibly put off by PIP and STAT commands. :(
 
> Should have used UnixV6 instead of RSX-11M/RSTS-E.
 
The TI 34010 Graphics processor communicated with the host CPU via
memory mapped registers. You'd load the address register with the
address in 34010 memory space, and then write to the data register.
Successive writes would increment the address register, so that you
could load graphics data by successive writes to the data register.
"Chris M. Thomasson" <nospam@nospam.no>: Apr 29 03:45PM -0700

FWIW, some, IMHO, fairly interesting C++ code for Field Based DLA:
 
https://plus.google.com/101799841244447089430/posts/am5EpMHcmig
 
https://github.com/ChrisMThomasson/CT_fieldDLA
 
https://en.wikipedia.org/wiki/Diffusion-limited_aggregation
 
that can be heavily multithreaded!
 
the code as is, creates the following rendering:
 
https://plus.google.com/101799841244447089430/posts/DfjAJbbdLGp
 
Four C++ files, that use the Cairo graphics lib along with the GLM library:
 
http://cairographics.org/
 
http://glm.g-truc.net/0.9.7/index.html
 
No need to follow random walks, follow field lines for DLA?
 
C++ seems like a _very_ nice place to implement this.
 
:^)
Jerry Stuckle <jstucklex@attglobal.net>: Apr 29 10:40AM -0400

On 4/29/2016 1:20 AM, Öö Tiib wrote:
> defines object or library file formats or application binary interfaces
> so they can. You however very verbosely keep failing to give examples of
> users of that freedom in Unix land.
 
And you can keep demanding all you want. One of these days, I might be
talking to one of my past clients and get the details. I don't remember
what every client I ever worked with runs.
 
But it's not important enough to me to bug them with trivial questions.
 
However, everyone else here seems to claim that ar is required to build
.a files, and all .o files are the same format. It shows just how
limited your experience is.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Jerry Stuckle <jstucklex@attglobal.net>: Apr 29 10:42AM -0400

On 4/29/2016 4:14 AM, Ian Collins wrote:
>> it wasn't gcc. However, it's not important enough for me to give a damn.
 
> So as usual you can't back up your nonsensical claims. Why do you
> bother posting bollocks? I guess you don't give a damn.
 
Nope, it's just not important enough for me to try to teach a pig to
sing. Your comments prove the extent of your ignorance.
 
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Jerry Stuckle <jstucklex@attglobal.net>: Apr 29 10:43AM -0400

On 4/29/2016 8:46 AM, Scott Lurndal wrote:
>> the educational world. Not even AT&T was using it very much for production.
 
> Interesting, indeed, as I was working for a University on
> a PDP-11/34 writing unix drivers for test hardware.
 
Let's see. You were working for a University. I said they were used in
the educational world. I guess to you a University is not part of the
educational world.
 
I guess you never learned comprehension at your "university".
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
"Öö Tiib" <ootiib@hot.ee>: Apr 29 08:44AM -0700

On Friday, 29 April 2016 17:41:06 UTC+3, Jerry Stuckle wrote:
> talking to one of my past clients and get the details. I don't remember
> what every client I ever worked with runs.
 
> But it's not important enough to me to bug them with trivial questions.
 
I do not demand. I say that it leaves your assertions bald and empty
denial of reality.
 
 
> However, everyone else here seems to claim that ar is required to build
> .a files, and all .o files are the same format. It shows just how
> limited your experience is.
 
You are moving goalposts here. Others claim that with advent of portable
operating systems some object file formats have been defined and used
on different kinds of systems. The formats are not used because someone
requires that. Formats are used because everybody wants to achieve
compatibility with others. Who does not falls out of pack and loses.
 
No one is required to make say .zip files using a PKZIP program and if
they use something else they are still not required to produce ZIP
format specified by ISO/IEC 21320-1:2015. Everybody just wants to.
Jerry Stuckle <jstucklex@attglobal.net>: Apr 29 12:23PM -0400

On 4/29/2016 11:44 AM, Öö Tiib wrote:
 
>> But it's not important enough to me to bug them with trivial questions.
 
> I do not demand. I say that it leaves your assertions bald and empty
> denial of reality.
 
And what you think is of absolutely no importance to me.
 
> on different kinds of systems. The formats are not used because someone
> requires that. Formats are used because everybody wants to achieve
> compatibility with others. Who does not falls out of pack and loses.
 
No, I have moved no goalposts. My statements have been consistent since
the start. Just because your limited experience hasn't exposed you to
other options does not mean they don't exist.
 
> No one is required to make say .zip files using a PKZIP program and if
> they use something else they are still not required to produce ZIP
> format specified by ISO/IEC 21320-1:2015. Everybody just wants to.
 
Now who's moving the goalposts - or at least bringing up another red
herring?
 
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Jerry Stuckle <jstucklex@attglobal.net>: Apr 29 02:28PM -0400

On 4/28/2016 5:01 PM, David Brown wrote:
> made it perfectly clear that I don't believe it can be done, and
> certainly don't know of any method. I have also made it clear that I
> will be happy to be proven wrong here.
 
Since you're completely incapable of a small challenge, here's how you
can do it:
 
file: endian.c:
===
#include <stdio.h>
 
union endian {
short s;
char c[sizeof(short)];
};
 
int main(void) {
union endian endian;
 
endian.s = 1;
if (endian.c[0])
printf("LITTLEENDIAN");
else
printf("BIGENDIAN");
return 0;
}
===
 
gcc endian.c -o endian
 
file: endiantest.c:
===
#include <stdio.h>
 
int main(void) {
 
#ifdef BIGENDIAN
printf("Big Endian defined\n");
#elif defined LITTLEENDIAN
printf("Little Endian defined\n");
#else
printf("No endian defined\n");

Fwd: 凱特王妃美衣風采被搶光?喬治小王子穿睡衣都能殺光底片!



Sent from my iPad

Begin forwarded message:

From: Sharon Kahn <sharon62kahn@gmail.com>
Date: April 27, 2016 at 7:08:34 PM CDT
Subject: Fwd: 凱特王妃美衣風采被搶光?喬治小王子穿睡衣都能殺光底片!




Subject: Fwd: Fwd: 凱特王妃美衣風采被搶光?喬治小王子穿睡衣都能殺光底片!



Digest for comp.lang.c++@googlegroups.com - 25 updates in 7 topics

"Öö Tiib" <ootiib@hot.ee>: Apr 28 10:20PM -0700

On Thursday, 28 April 2016 22:28:15 UTC+3, Jerry Stuckle wrote:
> > (pretty much like 'tar') and not some sort of gcc tool.
 
> Which does not mean that other tools can't include their own versions of
> library creation tools.
 
No one in this thread has said they can't. Neither C nor C++ standard
defines object or library file formats or application binary interfaces
so they can. You however very verbosely keep failing to give examples of
users of that freedom in Unix land.
Paavo Helde <myfirstname@osa.pri.ee>: Apr 29 08:21AM +0300

On 29.04.2016 0:50, David Brown wrote:
 
> A cross-compiler could pre-calculate the result of this expression at
> compile time - it knows the endianness of the target and can get this
> sort of thing right. But of course it is still not a constant expression.
 
This would basically require that in addition of generating machine code
the compiler would also contain a virtual machine for executing this
code. To my understanding, reinterpret_cast is forbidden in constexpr
exactly in order to avoid such burdens.
 
Cheers
Paavo
Ian Collins <ian-news@hotmail.com>: Apr 29 08:10PM +1200

On 04/29/16 10:09, Richard wrote:
> archive shall be printable."
> <http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ar.html>
 
> Neat! I didn't know that.
 
Neither did I, which just goes to show that most of us are never too old
to learn :)
 
--
Ian Collins
Ian Collins <ian-news@hotmail.com>: Apr 29 08:14PM +1200

On 04/29/16 09:39, Jerry Stuckle wrote:
 
> One of these days when I get around to it, I'll get ahold of one of my
> past customers and see what they use. I don't remember right now, but
> it wasn't gcc. However, it's not important enough for me to give a damn.
 
So as usual you can't back up your nonsensical claims. Why do you
bother posting bollocks? I guess you don't give a damn.
 
--
Ian Collins
David Brown <david.brown@hesbynett.no>: Apr 29 01:10PM +0200

On 29/04/16 07:21, Paavo Helde wrote:
 
> This would basically require that in addition of generating machine code
> the compiler would also contain a virtual machine for executing this
> code.
 
No, it is much simpler than that. For a case like this, the compiler
only needs to know the endianness of the target and it can figure out
the result - there is no need for full simulations. Note - I have tied
this code, as:
 
bool isLittleEndian(void) {
const int dummy = 1;
bool little_endian = *(reinterpret_cast<char *> (&dummy));
return little_endian;
}
 
A cross-compiler for embedded ARM devices optimised this to a simple
"return true;" equivalent.
 
Powerful compilers have quite complex simulators and target evaluators
built in. gcc is quite happy with a 32-bit host doing compile-time
calculation of the results of 64-bit or 128-bit arithmetic on a
different target. It will even do so for floating point, getting
bit-accurate results. (If it can't get bit-accurate results, it falls
back to generating run-time code for the target.)
 
 
> To my understanding, reinterpret_cast is forbidden in constexpr
> exactly in order to avoid such burdens.
 
I am not sure if that is the reason, or at least the only reason, why
reinterpret_cast is forbidden in constexpr. As a general point, memory
accesses are very limited in constexpr.
Paavo Helde <myfirstname@osa.pri.ee>: Apr 29 03:07PM +0300

On 29.04.2016 14:10, David Brown wrote:
> }
 
> A cross-compiler for embedded ARM devices optimised this to a simple
> "return true;" equivalent.
 
I hope it got it right (there are ARMs of both endiannesses).
 
> different target. It will even do so for floating point, getting
> bit-accurate results. (If it can't get bit-accurate results, it falls
> back to generating run-time code for the target.)
 
Yes, compilers can do very sophisticated optimizations. However, they
are not obliged to do them and as you say they can fall back to leave
some code unoptimized. This is not so with constexpr - if something is
marked constexpr, *all* compiler vendors must implement the needed
functionality and they *cannot* fall back to runtime code generation.
 
 
> I am not sure if that is the reason, or at least the only reason, why
> reinterpret_cast is forbidden in constexpr. As a general point, memory
> accesses are very limited in constexpr.
 
Probably for similar reasons.
 
Cheers
Paavo
David Brown <david.brown@hesbynett.no>: Apr 29 02:14PM +0200

On 29/04/16 14:07, Paavo Helde wrote:
 
>> A cross-compiler for embedded ARM devices optimised this to a simple
>> "return true;" equivalent.
 
> I hope it got it right (there are ARMs of both endiannesses).
 
It did. (I have also used gcc for big endian targets, and the compiler
got that right too.)
 
 
> Yes, compilers can do very sophisticated optimizations. However, they
> are not obliged to do them and as you say they can fall back to leave
> some code unoptimized.
 
Correct. If the compiler can't be sure of getting the compile-time
optimisation correct, then it should leave the code as run-time
calculations, and different compilers will vary in how much they can do
at compile time.
 
> This is not so with constexpr - if something is
> marked constexpr, *all* compiler vendors must implement the needed
> functionality and they *cannot* fall back to runtime code generation.
 
That is only sort-of correct, I believe. If you are using the constexpr
value as a constant expression (such as for template instantiation, or
the size of a C-style array), then it must be calculated at compile
time. But if the usage of the constexpr code would have been legal C++
without the constexpr, then the compiler /could/ use run-time
calculations - you are not /guaranteed/ compile-time optimisation. And
it is legal to have constexpr functions that contain features that are
only possible at run time, such as "throw" statements, or to call them
using run-time variables. In such cases, there is no way for the
compiler to handle them at compile time - it must be done at run time.
 
scott@slp53.sl.home (Scott Lurndal): Apr 29 12:46PM


>> 1977.
 
>Very interesting, since Unix had very limited usage in 1977 - mainly in
>the educational world. Not even AT&T was using it very much for production.
 
Interesting, indeed, as I was working for a University on
a PDP-11/34 writing unix drivers for test hardware.
scott@slp53.sl.home (Scott Lurndal): Apr 29 12:53PM


>I think my first use of unix was in 1978, but I didn't program on it
>until around 1979/1980. When you're young, you don't write these
>things down because who cares? LOL.
 
What I remember distinctly was how much of a breath of fresh
air Unix was after using TSS/8.24 on the PDP-8.
scott@slp53.sl.home (Scott Lurndal): Apr 29 12:55PM

>I don't think there was any sort of mechanism for accessing any code
>that wasn't provided as a pascal library or code written in p-code.
><https://en.wikipedia.org/wiki/UCSD_Pascal#UCSD_Pascal_and_the_p-System>
 
I believe you are correct. We used the Terak machines running UCSD pascal
for a while at the Uni. IIRC, they had a rudimentary IDE.
ram@zedat.fu-berlin.de (Stefan Ram): Apr 29 07:51AM

>Shouldn't it be up to the compiler to check whether a function or
>constructor is constexpr or not?
 
The compiler only sees the /declarations/ of library
functions, not the implementations.
 
In cases where the compiler /can/ see the implementations, a
change in the implementations of those functions then might
turn constexpr functions into non-constexpr functions which
in turn might break client code.
 
But the most fundamental piece of modern programming is
ram@zedat.fu-berlin.de (Stefan Ram): Apr 29 08:00AM

Supersedes: <constexpr-20160429085107@ram.dialup.fu-berlin.de>
[added more text at the end]
 
>Shouldn't it be up to the compiler to check whether a function or
>constructor is constexpr or not?
 
The compiler only sees the /declarations/ of library
functions, not the implementations.
 
In cases where the compiler /can/ see the implementations, a
change in the implementations of those functions then might
turn constexpr functions into non-constexpr functions which
in turn might break client code.
 
But the most fundamental piece of modern programming is
the separation of implementation and interface.
 
»constexpr« does not only mean that the function is
implemented to be a constexpr function right now, but also
that the publisher avows himself to keep it this way.
Marcel Mueller <news.5.maazl@spamgourmet.org>: Apr 29 08:57AM +0200

C++11 introduced constexpr for (some) strictly deterministic and
functional code. But now I need to write constexpr at many places in the
code to get the benefits from it.
 
Shouldn't it be up to the compiler to check whether a function or
constructor is constexpr or not? I mean similar to inline or register
which are no much more than optional hints nowadays. (Yes, I know,
inline implies weak linkage.)
 
I would prefer when every thing gets constexpr automatically wherever
possible. What should be the motivation to prevent a function to be
constexpr?
I could write a static assertion if I need to check whether an
expression satisfies this constraint. The compiler could do the same
when it requires a constexpr.
 
In fact this behavior was implemented from the very early days of the C
language as you always could write
int array[3+4];
where 3+4 is nothing else but a constexpr.
 
So I can't get why there is a need for the new keyword and the resulting
refactoring of library code for C++11 and above.
 
 
Marcel
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Apr 29 09:43AM +0200

On 29.04.2016 08:57, Marcel Mueller wrote:
 
> I can't get why there is a need for the new keyword and the resulting
> refactoring of library code for C++11 and above.
 
It means the compiler can (and must) tell you wherever you write
`constexpr` code that is beyond what can be `constexpr`, e.g.
inadvertently using dynamic allocation by involving a `std::string`.
 
So `constexpr` is part of the usual static type checking scheme.
 
Also, without it checking whether code could be evaluated at compile
time would incur some extra overhead for separate compilation (with
effectively whole program optimization invoked). Today compilers have
whole program optimization as an option. Because it has a cost, in
compilation time, size of object files, and restriction of use of features.
 
 
Cheers & hth.,
 
- Alf
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Apr 29 12:26AM +0100


> http://www.foxnews.com/world/2016/04/28/dutch-dreamer-hopes-to-bring-noahs-ark-replica-to-americas.html?intcmp=hplnws
 
> I want to give these guys a shout out for their work so far.
> I'm impressed with what they have accomplished.
 
Looks like a self indulgent vanity project to me.
 
/Flibble
Wouter van Ooijen <wouter@voti.nl>: Apr 29 09:35AM +0200


> http://www.foxnews.com/world/2016/04/28/dutch-dreamer-hopes-to-bring-noahs-ark-replica-to-americas.html?intcmp=hplnws
 
> I want to give these guys a shout out for their work so far.
> I'm impressed with what they have accomplished.
 
note (from their website) "At 410 feet long, 95 feet wide and 75 feet
high, the ark is half the size of the specifications described in the
Bible. It is made of cedar and pine and was built atop a steel barge ..."
 
So even at half the size and with modern woodcraft, they didn't try to
built it from wood. It is essentially a big cabin on top of a steel ship.
 
Note that I live in the Netherlands and I had never heared of this
project. We Dutch don't take religious controversies very serious any
more, otherwise the Dutch would have killed each other centuries ago.
(We did try, but in the end maintaining the Dykes was deemed more
important. Living next to a (different-)religious neighbour is to be
preferred over being dead on the bottom of a sea.)
 
Wouter "objects? No thanks!" van Ooijen
Lynn McGuire <lmc@winsim.com>: Apr 28 08:02PM -0500

Is there anything comparing the efficiency of a std::vector with a std::map ? I am using a std::vector in many circumstances with up
to 26,000 entries. Unfortunately, I have very little way of predicting the ultimate size of the vector so I am using push_back () to
add more entries instead of resize ().
 
I am having some performance issues and am suspecting the std::vector growing so much by a single increments is really slowing my
code down.
 
Or, should I be using reserve () to increase the size of my std::vector in increments of 10,000 instead of increments of 1 ?
http://en.cppreference.com/w/cpp/container/vector/reserve
 
Thanks,
Lynn
Daniel <danielaparker@gmail.com>: Apr 28 06:48PM -0700

On Thursday, April 28, 2016 at 9:02:58 PM UTC-4, Lynn McGuire wrote:
> add more entries instead of resize ().
 
> Or, should I be using reserve () to increase the size of my std::vector in
> increments of 10,000 instead of increments of 1 ?
 
You could always reserve 26,000 entries and shrink_to_fit if that turns out
to be excessive.
 
Also, make sure that the things that you're adding to the vector support
move semantics.
 
Perhaps try std::deque, but 26,000 doesn't sound to me like a lot of
entries. Make sure that the time to reallocate isn't spent doing copies
rather than moves.
 
Daniel
Paavo Helde <myfirstname@osa.pri.ee>: Apr 29 08:31AM +0300

On 29.04.2016 4:02, Lynn McGuire wrote:
> entries instead of resize ().
 
> I am having some performance issues and am suspecting the std::vector
> growing so much by a single increments is really slowing my code down.
 
std::vector::push_back() does not grow in single increments, otherwise
it could not be amortized O(1) complexity as required by the standard.
 
OTOH, insertion and lookup in a map is O(log N), which is much-much worse.
 
26,000 is a very small number.
 
IOW, do not try to optimize prematurely. If your program is too slow,
profile it first to find out bottlenecks.
 
HTH
Paavo
Marcel Mueller <news.5.maazl@spamgourmet.org>: Apr 29 08:06AM +0200

On 29.04.16 03.02, Lynn McGuire wrote:
> 26,000 entries. Unfortunately, I have very little way of predicting the
> ultimate size of the vector so I am using push_back () to add more
> entries instead of resize ().
 
You are fine. Using push_back() in a loop with n iterations will not
exceed O(n log n) in total.
 
> I am having some performance issues and am suspecting the std::vector
> growing so much by a single increments is really slowing my code down.
 
Use a profiler to track your performance issues. Probably they are
caused by something else.
 
> Or, should I be using reserve () to increase the size of my std::vector
> in increments of 10,000 instead of increments of 1 ?
> http://en.cppreference.com/w/cpp/container/vector/reserve
 
If you can approximately predict the upper bound of the size for an
individual vector, reserve() is fine. Otherwise it might be
counterproductive. Allocation too much memory can significantly degrade
cache efficiency, besides the waste of resources, of course.
 
Note that the situation changes significantly if you use insert()
instead. This yields to O(n²) in general, regardless of reserve().
This is the point where std::map comes into play. But do not expect too
much. std::map uses Red-Black Tree. This is quite ineffective for many
small objects, because of the allocation overhead. This is the price for
keeping iterators valid at insert and delete operations.
If the latter is not required B-Trees with reasonable node sizes (63 or
127) outperform std:map by far. Unfortunately there is no B-Tree in the
std:: namespace.
 
 
Marcel
Marcel Mueller <news.5.maazl@spamgourmet.org>: Apr 29 07:47AM +0200

On 27.04.16 23.45, Ian Collins wrote:
 
> Do you need pod, or just standard layout?
 
> If the latter, you could skip the helper and give rPUp constexpr
> constructors, something like
 
AFAIR members of a union must not contain constructors.
This seems not to be true, it compiles also when rPUp has a constructor.
 
I wonder how the compiler can handle this. Which constructor should be
invoked when some of the union members have a constructor?
In fact it works somehow. - Puzzled...
 
 
Marcel
"Öö Tiib" <ootiib@hot.ee>: Apr 28 11:01PM -0700

On Friday, 29 April 2016 08:47:15 UTC+3, Marcel Mueller wrote:
 
> I wonder how the compiler can handle this. Which constructor should be
> invoked when some of the union members have a constructor?
> In fact it works somehow. - Puzzled...
 
Unions in C++ have changed quite a lot with C++11. See Stroustrup's C++11
FAQ about unions for starters:
http://www.stroustrup.com/C++11FAQ.html#unions
JiiPee <no@notvalid.com>: Apr 29 12:41AM +0100

On 28/04/2016 22:17, Barry Schwarz wrote:
> definitely not. Do you think
> char* p = k;
> does any kind of copy from the array?
 
no, but:
 
char aa[] = "Hello";
 
*does* copy the hello into it. thats what I mean.... that array is not
"consistant" : sometimes it means copy sometimes it means pointer copy.
But I understand that now....its ok.
 
JiiPee <no@notvalid.com>: Apr 29 12:44AM +0100

On 28/04/2016 20:35, Chris Vine wrote:
> void foo(char (&a)[4]) {}
 
> 'a' retains its quality as a reference to an array of char of size 4,
> and it will refuse to compile if passed a char array of any other size.
 
interesting.. good to know
Barry Schwarz <schwarzb@dqel.com>: Apr 28 09:44PM -0700


>*does* copy the hello into it. thats what I mean.... that array is not
>"consistant" : sometimes it means copy sometimes it means pointer copy.
>But I understand that now....its ok.
 
Your declaration above is not an assignment, despite what it looks
like. It is initialization.
 
And the same "inconsistency" applies to initialization. Your
declaration will copy data while
char *bb = "Hello";
will not.
 
--
Remove del for email
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.

Thursday, April 28, 2016

Digest for comp.lang.c++@googlegroups.com - 25 updates in 4 topics

Jerry Stuckle <jstucklex@attglobal.net>: Apr 28 03:28PM -0400

On 4/27/2016 9:33 PM, Öö Tiib wrote:
 
>> Yup, when you use the gcc compiler and tools.
 
> Jerry, you go too far here in that denial. The 'ar' is Unix utility
> (pretty much like 'tar') and not some sort of gcc tool.
 
Which does not mean that other tools can't include their own versions of
library creation tools.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Jerry Stuckle <jstucklex@attglobal.net>: Apr 28 03:29PM -0400

On 4/28/2016 12:21 AM, Ian Collins wrote:
>>> incompatibilities.
 
>> It does if you use the ar from the appropriate toolkit.
 
> The only "toolkit" ar comes from is the operating system.
 
Which does not prohibit another toolkit from having their own version.
 
I find it interesting that Linux programmers, who spend virtually all
their time with one OS and one compiler, think the entire world works
that way.
 
It doesn't, as people who work on multiple OS's and with multiple
compilers understand.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Jerry Stuckle <jstucklex@attglobal.net>: Apr 28 03:32PM -0400

On 4/28/2016 9:57 AM, Scott Lurndal wrote:
 
>> Believe I've been working with unix for probably a lot longer than you
>> have - back around 1979 (although not continuously since that time)
 
> 1977.
 
Very interesting, since Unix had very limited usage in 1977 - mainly in
the educational world. Not even AT&T was using it very much for production.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Jerry Stuckle <jstucklex@attglobal.net>: Apr 28 03:48PM -0400

On 4/28/2016 4:13 AM, David Brown wrote:
> calling conventions for libraries? How would printf work? (Variable
> argument functions are easily handled with C calling conventions, but
> not with Pascal conventions.)
 
Functions like printf are part of the C library, so of course they use C
calling conventions. You don't call them from PASCAL or COBOL, for
instance.
 
But non-C derived languages such as FORTRAN and COBOL do not use C
calling conventions.
 
And BTW - Windows is written in C, also. So are the Windows libraries.
But the calling convention into the system libraries is not C.
 
> world (and its DOS predecessor) where there is a jumble of local
> conventions, often designed specifically for vendor lock-in rather than
> cooperation.
 
Yes, there are many different OS's. But if you want to be able to use
languages such as Fortran and Cobol, the OS libraries need to use
calling conventions supported by those languages.
 
 
> Yes, there have been other Pascals. But the users of Delphi and its
> predecessors Borland Pascal and Turbo Pascal probably outweigh the
> combined number of users for every other Pascal by a factor of a hundred.
 
Once again, your ignorance shows. For one thing, there were millions of
students around the world using UCSD Pascal in the late 70's and early
80's - ling before Delphi, Borland Pascal, and so on. It was a common
language taught in many universities.
 
But beyond that, large and medium companies (including IBM) used Pascal
extensively in the 1980's. But they were using enterprise grade
products, not Delphi.
 
> calling conventions. I don't know what calling conventions were used on
> UCSD P-code systems - I was perhaps 9 or 10 when I used that on a VAX,
> and did not get far beyond a "Hello, world" program.
 
The calling conventions were similar, for those machines which had a
hardware stack. For those without one, values were placed in a
"parameter passing area" and the address of that area placed in a register.
 
> a total confidence even when your claims are pure fantasy, and everyone
> around you is laughing. I am sure you would make an excellent poker
> player, but I am very glad I don't have to deal with you professionally.)
 
No, the difference is your "knowledge", AFAICT, is based pretty much on
one set of tools on one OS. And you think the rest of the world works
that way.
 
> way to do it - but that would only give you limited capabilities. In
> particular, to be really useful, you need the endianness to be testable
> in the preprocessor.
 
Just a question - a problem similar to what consultants have to solve on
a regular basis. Just seeing if you really knew what you were talking
about. I see you don't.
 
 
> Certainly I will publicise your success in c.l.c and c.l.c++, and it
> will be seen even by the many people who have killfiled you. If not,
> then your reputation - low as it is - will drop further.
 
Yes, I raised the challenge. It's up to you to solve it. I have
(actually did several years ago). Come on, David, give it a go.
 
Or do you need someone to hand feed you everything?
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Ian Collins <ian-news@hotmail.com>: Apr 29 08:11AM +1200

On 04/29/16 07:29, Jerry Stuckle wrote:
 
>>> It does if you use the ar from the appropriate toolkit.
 
>> The only "toolkit" ar comes from is the operating system.
 
> Which does not prohibit another toolkit from having their own version.
 
Name one.
 
> I find it interesting that Linux programmers, who spend virtually all
> their time with one OS and one compiler, think the entire world works
> that way.
 
I'm not a Linux programmer.
 
--
Ian Collins
Paavo Helde <myfirstname@osa.pri.ee>: Apr 28 11:28PM +0300

On 28.04.2016 22:48, Jerry Stuckle wrote:
> Just a question - a problem similar to what consultants have to solve on
> a regular basis.
 
I think we really do have a highly-paid consultant here! And he
routinely solves the unsolvable problems! Why don't we just sit all back
in awe and watchen das blinkenlights?
 
As for solving the endianness problem, the practical solution (as
opposed to "complete, portable and standard-conforming solution") is
indeed really simple:
 
#include <boost/detail/endian.hpp>
 
#if defined(BOOST_LITTLE_ENDIAN)
const bool bigEndian = false;
#elif defined(BOOST_BIG_ENDIAN)
const bool bigEndian = true;
#else
#error Unsupported platform.