Giter Club home page Giter Club logo

Comments (3)

degski avatar degski commented on July 20, 2024 1

That depends (on Windows) where you get the memory from, as far as I know (VirtualMemory is zeroed), the padding bytes are undefined (so it depends on what the allocator did). On the other hand, you can just set them to zero by making the padding part of your type:

struct alignas ( 8 ) type  { int val, _ = 0; };

from memory-allocators.

kochol avatar kochol commented on July 20, 2024

It is still a bug.

from memory-allocators.

degski avatar degski commented on July 20, 2024

I'm just pointing out to how to keep the padding of an object under control as it might be that comparison might depend on it (like with std::memcmp ) as the size of the object includes the padding (so one could be more careful from the get-go), it will not compare equal when the padding differs, while they all have equivalent (e.i. not unequal) value (equal is not necessarily equal to not unequal, its' defined as equivalence). Somewhere someone needs to put a zero, and/or make sure the padding is not considered in any comparison, initing the padding is an option (and makes clear there is some unused space in the struct available for future use):

struct alignas ( 16 ) type2  { long long value, reserved_ = 0; };

The trick is to have no padding, which can be statically asserted and/or sfinaed, specilized.

from memory-allocators.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.