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


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

Re: This will work or not?

Path csiph.com!1.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!news.albasani.net!.POSTED!not-for-mail
From Melzzzzz <mel@zzzzz.com>
Newsgroups comp.lang.c++
Subject Re: This will work or not?
Date Wed, 31 Aug 2016 15:59:55 +0200
Organization albasani.net
Lines 53
Message-ID <20160831155955.418179d7@maxa-pc> (permalink)
References <20160831145918.45a0c396@maxa-pc> <nq6n13$1qdi$1@gioia.aioe.org>
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-Trace news.albasani.net qQuBA/j75fqKQHTkvEqPf2OKHPj1OMGHQ0xFfGJ1+lPCHkt6cdddzqvTLDpFJMqKlCBkWsfsdHM1xvbJTYekVg==
NNTP-Posting-Date Wed, 31 Aug 2016 13:59:55 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="V5PD1Qih+U33DmALB/8OI6q4cKOwI+5+0JQK82LG6joQeoHSW7HIyaD0uT8ZjKq/TgZzhswvqesAi8gQFxuCj+15ktMHg/kF5ab3eXiFDLipo+zqFXAja/RKWdzJjchO"; mail-complaints-to="abuse@albasani.net"
X-Newsreader Claws Mail 3.14.0 (GTK+ 2.24.30; x86_64-unknown-linux-gnu)
Cancel-Lock sha1:njG3ljOMYueIdPQR1GVOMHVkuWU=
Xref csiph.com comp.lang.c++:44633

Show key headers only | View raw


On Wed, 31 Aug 2016 15:45:07 +0200
Manfred <noname@invalid.add> wrote:

> On 8/31/2016 2:59 PM, Melzzzzz wrote:
> > Code in question is like this:
> >
> > struct Problem{
> > 	uint32_t a;
> > 	uint32_t b;
> > 	uint64_t c;
> > 	uint32_t d;
> > 	bool check_it() {
> > 		for (uint32_t* i = &a;i != &d; ++i)
> > 			if (*i>0) return true;
> > 		return false;
> > 	}
> >
> > };
> >
> > I am not sure if this will work, so if someone has clear explanation
> > why it will work (or not) , I would be grateful.
> >  
> 
> You need to specify __attribute__((__packed__)) for a, b, c, d (esp.
> d) 

Oh I forgot to say that that attribute is specified.


Moreover, the guaranteed ordering of a, b, c, d needs to be
> verified with the standard:
> iso 9.2.13 (draft 2014-11-19):
> "Nonstatic data members of a (non-union) class with the same access 
> control (Clause 11) are allocated so that later members have higher 
> addresses within a class object. The order of allocation of
> non-static data members with different access control is unspecified
> (Clause 11). Implementation alignment requirements might cause two
> adjacent members not to be allocated immediately after each other; so
> might requirements for space for managing virtual functions (10.3)
> and virtual base classes (10.1)."
> 
> Obviously the test may only work for comparison with 0.
> I would not classify this practice as good, in the sense that I would 
> not do this in production code.

I agree.

> 
> Best Regards,
> M.
> 

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


Thread

This will work or not? Melzzzzz <mel@zzzzz.com> - 2016-08-31 14:59 +0200
  Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-08-31 15:20 +0200
    Re: This will work or not? mark <mark@invalid.invalid> - 2016-08-31 16:05 +0200
      Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-08-31 16:19 +0200
    Re: This will work or not? scott@slp53.sl.home (Scott Lurndal) - 2016-08-31 14:20 +0000
    Re: This will work or not? Bo Persson <bop@gmb.dk> - 2016-08-31 18:53 +0200
      Re: This will work or not? Tim Rentsch <txr@alumni.caltech.edu> - 2016-09-01 09:03 -0700
        Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-09-01 22:45 +0200
          Re: This will work or not? Tim Rentsch <txr@alumni.caltech.edu> - 2016-09-01 18:08 -0700
            Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-09-02 09:24 +0200
              Re: This will work or not? Tim Rentsch <txr@alumni.caltech.edu> - 2016-09-04 06:31 -0700
                Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-09-04 20:19 +0200
  Re: This will work or not? Manfred <noname@invalid.add> - 2016-08-31 15:45 +0200
    Re: This will work or not? Melzzzzz <mel@zzzzz.com> - 2016-08-31 15:59 +0200
    Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-08-31 16:22 +0200
      Re: This will work or not? Manfred <noname@invalid.add> - 2016-08-31 17:06 +0200
        Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-08-31 19:29 +0200
          Re: This will work or not? Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2016-08-31 21:52 +0100
            Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-09-01 09:07 +0200
              Re: This will work or not? Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2016-09-01 12:30 +0100
            Re: This will work or not? Tim Rentsch <txr@alumni.caltech.edu> - 2016-09-01 09:01 -0700
              Re: This will work or not? Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2016-09-01 18:16 +0100
                Re: This will work or not? Tim Rentsch <txr@alumni.caltech.edu> - 2016-09-01 18:37 -0700
                Re: This will work or not? Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2016-09-02 10:42 +0100
                Re: This will work or not? Tim Rentsch <txr@alumni.caltech.edu> - 2016-09-04 06:59 -0700
          Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-08-31 23:17 -0400
            Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-09-01 09:35 +0200
              Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-01 15:34 -0400
                Re: This will work or not? me <crisdunbar@gmail.com> - 2016-09-01 13:50 -0700
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-01 21:01 -0400
                Re: This will work or not? me <crisdunbar@gmail.com> - 2016-09-01 19:02 -0700
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-01 22:17 -0400
                Re: This will work or not? me <crisdunbar@gmail.com> - 2016-09-02 08:19 -0700
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-02 12:39 -0400
                Re: This will work or not? me <crisdunbar@gmail.com> - 2016-09-02 12:26 -0700
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-02 16:38 -0400
                Re: This will work or not? me <crisdunbar@gmail.com> - 2016-09-02 13:51 -0700
                Re: This will work or not? me <crisdunbar@gmail.com> - 2016-09-02 14:16 -0700
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-02 19:58 -0400
                Re: This will work or not? Paavo Helde <myfirstname@osa.pri.ee> - 2016-09-02 23:56 +0300
                Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-09-03 17:58 +0200
                Re: This will work or not? Manfred <noname@invalid.add> - 2016-09-02 11:41 +0200
                Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-09-02 12:27 +0200
                Re: This will work or not? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-02 12:37 +0100
                Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-09-02 17:39 +0200
                Re: This will work or not? Melzzzzz <mel@zzzzz.com> - 2016-09-02 17:40 +0200
                Re: This will work or not? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-02 16:54 +0100
                Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-09-02 20:22 +0200
                Re: This will work or not? Richard Damon <Richard@Damon-Family.org> - 2016-09-02 08:04 -0400
                Re: This will work or not? BartC <bc@freeuk.com> - 2016-09-02 13:51 +0100
                Re: This will work or not? Richard Damon <Richard@Damon-Family.org> - 2016-09-02 21:48 -0400
                Re: This will work or not? Manfred <noname@invalid.add> - 2016-09-02 15:17 +0200
                Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-09-02 17:46 +0200
                Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-09-01 23:14 +0200
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-01 21:02 -0400
                Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-09-02 09:35 +0200
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-02 08:50 -0400
                Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-09-02 17:59 +0200
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-02 12:49 -0400
                Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-09-02 20:36 +0200
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-02 16:32 -0400
                Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-09-03 18:08 +0200
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-03 18:25 -0400
                Re: This will work or not? Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-09-03 23:51 +0100
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-03 21:48 -0400
                Re: This will work or not? Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-09-04 03:48 +0100
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-03 23:05 -0400
                Re: This will work or not? Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-09-04 05:02 +0100
                Re: This will work or not? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-04 10:57 +0100
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-04 09:40 -0400
                Re: This will work or not? Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-09-04 16:39 +0100
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-04 12:46 -0400
                Re: This will work or not? Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-09-04 17:51 +0100
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-04 13:07 -0400
                Re: This will work or not? Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-09-04 18:37 +0100
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-04 17:16 -0400
                Re: This will work or not? Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-09-04 22:23 +0100
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-04 18:54 -0400
                Re: This will work or not? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-09-04 09:58 -0700
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-04 13:08 -0400
                Re: This will work or not? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-09-04 10:21 -0700
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-04 17:18 -0400
                Re: This will work or not? Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-09-04 22:24 +0100
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-04 18:56 -0400
                Re: This will work or not? Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-09-05 00:27 +0100
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-04 22:53 -0400
                Re: This will work or not? Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-09-05 18:18 +0100
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-05 15:27 -0400
                Re: This will work or not? Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-09-05 20:32 +0100
                Re: This will work or not? woodbrian77@gmail.com - 2016-09-05 14:07 -0700
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-05 18:15 -0400
                Re: This will work or not? Ike Naar <ike@iceland.freeshell.org> - 2016-09-05 20:12 +0000
                Re: This will work or not? Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-09-05 22:05 +0100
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-05 18:16 -0400
                Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-09-06 08:47 +0200
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-06 09:12 -0400
                Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-09-06 16:31 +0200
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-06 11:20 -0400
                Re: This will work or not? bighe.trole@gmail.com - 2016-09-04 18:55 -0700
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-04 22:55 -0400
                Re: This will work or not? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-09-04 17:17 -0700
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-04 22:57 -0400
                Re: This will work or not? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-09-05 11:20 -0700
                Re: This will work or not? Luuk <luuk@invalid.lan> - 2016-09-04 18:54 +0200
                Re: This will work or not? Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-09-04 17:59 +0100
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-04 13:08 -0400
                Re: This will work or not? David Brown <david.brown@hesbynett.no> - 2016-09-04 20:25 +0200
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-04 17:20 -0400
                Re: This will work or not? Öö Tiib <ootiib@hot.ee> - 2016-09-04 02:36 -0700
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-04 09:41 -0400
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-03 21:49 -0400
                Re: This will work or not? Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2016-09-04 03:49 +0100
                Re: This will work or not? Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-03 23:06 -0400
                Re: This will work or not? woodbrian77@gmail.com - 2016-09-03 21:16 -0700
  Re: This will work or not? Vir Campestris <vir.campestris@invalid.invalid> - 2016-08-31 21:08 +0100
  Re: This will work or not? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2016-09-01 02:28 +0200
    Re: This will work or not? Öö Tiib <ootiib@hot.ee> - 2016-09-01 01:28 -0700
    Re: This will work or not? "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-09-02 12:06 -0700
  Re: This will work or not? Öö Tiib <ootiib@hot.ee> - 2016-09-05 02:21 -0700
    Re: This will work or not? Melzzzzz <mel@zzzzz.com> - 2016-09-05 13:38 +0200
  Re: This will work or not? Juha Nieminen <nospam@thanks.invalid> - 2016-09-05 11:34 +0000
    Re: This will work or not? Melzzzzz <mel@zzzzz.com> - 2016-09-05 13:36 +0200
      Re: This will work or not? Vir Campestris <vir.campestris@invalid.invalid> - 2016-09-05 21:25 +0100

csiph-web