Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #71288

Re: std::atomic<T>::is_lock_free()

Path csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups comp.lang.c++
Subject Re: std::atomic<T>::is_lock_free()
Date Sat, 11 Jan 2020 06:41:46 -0800
Organization A noiseless patient Spider
Lines 52
Message-ID <86h8122gyd.fsf@linuxsc.com> (permalink)
References <qqdvha$nka$1@news.albasani.net> <qqjv8e$n35$2@news.albasani.net> <beb9fe49-da6c-4488-a435-5aa71a070782@googlegroups.com> <qqjvki$n35$4@news.albasani.net> <qqkhm9$1e2a$1@gioia.aioe.org> <qqlnp9$3ed$1@news.albasani.net> <98e27cbe-79a4-4875-8aaa-a45c1eab293d@googlegroups.com> <qqo4i8$rl5$1@news.albasani.net> <4a9ef580-84eb-4782-8d9a-440504086ca1@googlegroups.com> <qqp76b$o3q$1@news.albasani.net> <c000d68d-bc76-4ff9-bc54-d23d6067ebc8@googlegroups.com> <qqpf3c$ff3$1@news.albasani.net> <633f2371-1a23-4ba5-a2ac-1de2b8109a9b@googlegroups.com> <qqpg75$d6m$1@news.albasani.net> <b294252d-efe1-4ec4-9314-614aed5c541b@googlegroups.com> <qqrn7d$efh$1@news.albasani.net> <3d0d466e-34ea-458a-9933-045be32bbf39@googlegroups.com> <qqtf31$ccd$1@news.albasani.net> <86721e66-6079-42a0-8be5-be8342a6f4f3@googlegroups.com> <864kyna7m2.fsf@linuxsc.com> <53cf34eb-a6b7-4459-aef9-ec3297bdccb0@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Injection-Info reader02.eternal-september.org; posting-host="a658bb27d1b88b897660621da5fe7a9e"; logging-data="15863"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/4r4R+xc9yjleydOLLvgAn3OlTknTRJ0A="
User-Agent Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock sha1:/yVp+k1IXpRPKq/kdjeeSKs2K/s= sha1:ll617OHz3isH+AaFD5OCYCBKjEo=
Xref csiph.com comp.lang.c++:71288

Show key headers only | View raw


Tiib writes:

> On Friday, 29 November 2019 01:45:04 UTC+2, Tim Rentsch  wrote:
>
>> Tiib <ootiib@hot.ee> writes:
>>
>>> On Monday, 18 November 2019 08:52:27 UTC+2, Bonita Montero  wrote:
>>>
>>>>>>> Nonsense.  What is aligned or misaligned is up to compiler
>>>>>>> itself to decide.
>>>>>>
>>>>>> Wrong.  If you pack your members tighter than alignof(membertype)
>>>>>> allows this is not conforming.
>>>>>
>>>>> That is a bald and groundless assertion.
>>>>
>>>> "Object types have alignment requirements (6.9.1, 6.9.2) which place
>>>> restrictions on the addresses at which an object of that type may be
>>>> allocated. ...
>>>
>>> ...
>>> The alignment required for a type might be different when it is used
>>> as the type of a complete object and when it is used as the type of
>>> a subobject.
>>> ...
>>
>> No it cannot.  Refer to n4659, section 6.11, paragraph 1.  Note
>> in particular the last sentence, which says in part (with my
>> emphasis added):
>>
>>     An object type imposes an alignment requirement on EVERY
>>     OBJECT of that type
>>
>> There is no provision for the alignment varying according to
>> whether the object is a complete object or a subobject.
>
> Very next paragraph #2 says that:
> "The alignment required for a type might be different when it is used
> as the type of a complete object and when it is used as the type of
> a subobject."

So it does.  Interesting.

(It happens that in the document I consulted, these two paragraphs
were split by a page boundary, which makes the second paragraph
easy to miss.  It would be better to have the two conflicting
statements be in a single paragraph.)

I note that the example relies on virtual base classes.  This
explains why the special case is there.  ISTM that having the two
cases be different is poorly thought out, as it makes the notion
of alignment be almost meaningless.  But, that's C++ for ya.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Re: std::atomic<T>::is_lock_free() Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-11-28 15:44 -0800
  Re: std::atomic<T>::is_lock_free() Öö Tiib <ootiib@hot.ee> - 2019-11-28 16:43 -0800
    Re: std::atomic<T>::is_lock_free() Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-01-11 06:41 -0800

csiph-web