Git Product home page Git Product logo

Comments (8)

hsutter avatar hsutter commented on August 25, 2024

In principle, a conforming compiler should not eliminate the Ensures that depends on the memset, then also eliminate the memset. However, "as-if" would allow eliding them all by treating them as dead writes.

It seems like we need to say something about Ensures being treated as I/O as part of the side effects of the program. Saying that would require (tiny) language support.

Suggestion: What if in SS-assertions, under the definition of Ensures, we added this:

Every access of a named object mentioned in an argument to Ensures shall be treated as a volatile access.

from cppcoreguidelines.

AndrewPardoe avatar AndrewPardoe commented on August 25, 2024

Editors discussed 8 Dec 2015 and on 14 Dec 2015.

from cppcoreguidelines.

hsutter avatar hsutter commented on August 25, 2024

We intend to change the example to something else, and address this particular security example as part of a new security profile (likely with a secure buffer type or wrapper).

from cppcoreguidelines.

AndrewPardoe avatar AndrewPardoe commented on August 25, 2024

Andrew, please add an "enhancement" label about security. (Done)

from cppcoreguidelines.

AndrewPardoe avatar AndrewPardoe commented on August 25, 2024

Notes: There are a few issues entangled here. Contracts today are macro-based. But when we have contracts as a language feature, compilers are prohibited from propagating any information into or out of contracts that will introduce undefined behavior in the contract.

We need to add a sentence that refers to Ensures and notes that while current compilers may have trouble with this we can at least express the intent.

from cppcoreguidelines.

MikeGitb avatar MikeGitb commented on August 25, 2024

compilers are prohibited from propagating any information into or out of contracts that will introduce undefined behavior in the contract

I don't understand what this is supposed to mean. The problem is not that there is undefined behavior in the contract check. The problem is the as-if rule: there is no way for a program to read the original contents of the buffer after the memset EXCEPT if it exhibits undefined behavior in some DIFFERENT location (e.g. buffer overflow/reading uninitialized stack variables).

If contracts really are expected to disallow optimizations based on the as-if rule (e.g. via treating the operands as volatile as suggested by Herb) I'm expecting a significant/unacceptable slowdown of c++ programs in the future.

from cppcoreguidelines.

AndrewPardoe avatar AndrewPardoe commented on August 25, 2024

Revisited this issue today. We'd like to continue delaying action on it whilst the Committee discusses Contracts.

from cppcoreguidelines.

dksmiffs avatar dksmiffs commented on August 25, 2024

Suggest:

  1. preface this issue title with "I.7 " for benefit of new readers
  2. improve the // better comment in I.7's second example, quoted by @comex in OP. This comment could summarize some of the discussion on this issue thread. Something like:
    // better, b/c expresses intent - but even better solution will come with Contracts

from cppcoreguidelines.

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.