User defined qualifiers

Tags: c++ c++11 c++14
Question!

I thought about a little language extension for C++ and wrote Draft for a proposal (http://pdfcast.org/pdf/user-defined-type-qualifiers-1).

The idea is, that a user can define qualifiers like const and volatile himself, for ensuring some what qualifies code (i.e. methods) only calls same qualified.

The question is if this would collide with any language rules or if I missed anything.



Answers

Not really on-topic for StackOverflow. But yeah, "user-defined type qualifiers" is a neat idea, and one with a long history. They're commonly used for taint analysis (i.e., making sure user-controlled and potentially malicious bits aren't used as if they were trusted bits; making sure all your HTML is properly escaped before you display it; that sort of thing).

http://www.cs.umd.edu/~jfoster/papers/toplas-quals.pdf has taint analysis as its main motivation, but also mentions secure information flow (i.e., making sure sensitive information such as cryptographic key bits don't leak out into the non-secure parts of the code).

That said, for most applications, "user-defined data types" suffice. You can almost always mechanically transform, e.g. std::string [[tainted]] x into Tainted



This video can help you solving your question :)
By: admin