Sunday, June 6, 2021

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

"Alf P. Steinbach" <alf.p.steinbach@gmail.com>: Jun 07 12:22AM +0200

On 6 Jun 2021 22:27, Vir Campestris wrote:
> of the function.
 
> Maybe on entry begin is in eax, and end in rdi, which would explain the
> second instruction. But what's it doing with rsi?
 
Possibly you've assumed that the examples are expressed with the same
syntax.
 
The MSVC example uses Intel syntax, where e.g. `sub rdx, rcx` means `rdx
:= rdx - rcx`.
 
So in the MSVC example `rdx` and `rcx` hold the arguments on entry.
 
The gcc example uses AT&T syntax, where e.g. `movq %rsi, %rax` means
`rax := rsi`. I.e. the opposite order of the instruction arguments.
 
So in the gcc example `rsi` and `rdi` hold the arguments on entry.
 
One can tell gcc (or at least g++) to use the less noisy and more
conventional, in short more reasonable, Intel syntax via option
`-masm=intel`, unless I recall the details of that incorrectly.
 
 
Cheers,
 
- Alf
Keith Thompson <Keith.S.Thompson+u@gmail.com>: Jun 06 04:10PM -0700

> memory models, pointer arithmetic only works in a single segment, and
> accordingly the arrays are limited to a single segment. There is no
> such limitation for struct members.
 
I believe there is. Without that limitation, the offsetof macro
wouldn't work.
 
 
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */
Keith Thompson <Keith.S.Thompson+u@gmail.com>: Jun 06 04:20PM -0700

> type family char / signed char / unsigned char all had this property,
> but if you actually accessed the values, signed char (and char is
> signed) had the possibility of a trap value (-0).
 
I think you meant "(and char *if* signed)".
 
As of C++17, signed types including signed char can use two's
complement, ones' complement, or signed magnitude, but:
For unsigned narrow character types, each possible bit pattern of
the value representation represents a distinct number. These
requirements do not hold for other types.
which means that plain char and signed char have no trap representations
and no padding bits.
 
Drafts of C++20 permit only two's complement for signed integer types.
(You're unlikely to find a pre-C++20 implementation that doesn't already
meet that requirement.)
 
I haven't looked into what the standard says about aliasing arbitrary
objects with arrays of signed char.
 
 
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */
Vir Campestris <vir.campestris@invalid.invalid>: Jun 06 09:30PM +0100

On 01/06/2021 10:06, Bonita Montero wrote:
> -O3
> There are also benchmarks which run faster with clang,
> but most run faster with cl.
 
I found some code the other day that was faster with O3 on GCC but Ofast
on clang. (or it could have been the other way around).
 
Always benchmark if performance matters that much to you.
 
Andy
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: