- Is this undefined behavior? - 4 Updates
- [Jesus Loves You] Society's end - 3 Updates
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Jun 16 03:33PM -0700 On 6/16/2020 8:29 AM, Paavo Helde wrote: > trigger implicit object creation." > I gather all this fuss is about allowing type-based alias analysis. > Reinterpret_cast works directly against this idea. Wrt the paper, a natural C program example: struct X { int a, b; }; X *make_x() { X *p = (X*)malloc(sizeof(struct X)); p->a = 1; p->b = 2; return p; } Would would one need to cast the return value of malloc to (X*)? |
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Jun 16 03:39PM -0700 On 6/16/2020 3:33 PM, Chris M. Thomasson wrote: > return p; > } > Would would one need to cast the return value of malloc to (X*)? Why would one need to cast the return value? void* can do it as is, right? In pure C... |
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Jun 17 12:05AM +0100 On Tue, 16 Jun 2020 15:39:25 -0700 > > Would would one need to cast the return value of malloc to (X*)? > Why would one need to cast the return value? void* can do it as is, > right? In pure C... It is C-style code which will compile in C++ but has undefined behaviour in C++ - the latter (undefined behaviour) being the point of the example. As it happens it won't compile in C because it is missing the struct tag before the various references to X* and there is no typedef. The cast of the return value of malloc is not needed in C. I don't think the example is intended as a guide to writing good C. |
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Jun 16 04:11PM -0700 On 6/16/2020 4:05 PM, Chris Vine wrote: > the struct tag before the various references to X* and there is no > typedef. The cast of the return value of malloc is not needed in C. > I don't think the example is intended as a guide to writing good C. Touche! So, basically, I need to use placement new and explicit dtor via calling the dtor ~Type(). Then it becomes a "real object" in C++. I thought that POD would be different in a sense. |
rick.c.hodgin@gmail.com: Jun 16 02:18PM -0700 An excellent teaching and calling: https://www.youtube.com/watch?v=L1-hxP7l7Rw -- Rick C. Hodgin |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jun 16 10:38PM +0100 > You are worth being saved. Call upon Jesus and escape the > coming tribulation. Make your future sure. Teach you > family, friends, co-workers, and others in your life. And Satan invented fossils, yes? /Flibble -- "Snakes didn't evolve, instead talking snakes with legs changed into snakes." - Rick C. Hodgin "You won't burn in hell. But be nice anyway." – Ricky Gervais "I see Atheists are fighting and killing each other again, over who doesn't believe in any God the most. Oh, no..wait.. that never happens." – Ricky Gervais "Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Byrne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?" "I'd say, bone cancer in children? What's that about?" Fry replied. "How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil." "Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say." |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jun 16 11:34PM +0100 > An excellent teaching and calling: > https://www.youtube.com/watch?v=L1-hxP7l7Rw An excellent response to that teaching and calling: https://www.youtube.com/watch?v=42UCpOzTbNU /Flibble -- "Snakes didn't evolve, instead talking snakes with legs changed into snakes." - Rick C. Hodgin "You won't burn in hell. But be nice anyway." – Ricky Gervais "I see Atheists are fighting and killing each other again, over who doesn't believe in any God the most. Oh, no..wait.. that never happens." – Ricky Gervais "Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Byrne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?" "I'd say, bone cancer in children? What's that about?" Fry replied. "How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil." "Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say." |
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:
Post a Comment