Boost logo

Boost :

Subject: Re: [boost] [array] compile-time checked access
From: Jens Auer (jensa_at_[hidden])
Date: 2012-11-05 09:08:33


I cannot see any code but only newlines in your post, so I will not respond to the example. The sort of analysis you are looking for is done by static analysis tools (as far as possible, there are limitations). A classic one would be lint, but I don't know if they catch such errors. The documentation says that they do value tracking and some form of abstract interpretation. You should be able to find a lot of (commercial) tools with google if you search for static analysis c++. Klocwork and QA Systems are well-known vendors I know about.

The MS compiler also has some static analysis facilities and there exists a free static analyzer based on clang:

Best regards,

-----Ursprüngliche Nachricht-----
Von: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] Im Auftrag von Tobias Loew
Gesendet: Montag, 5. November 2012 09:51
An: boost_at_[hidden]
Betreff: [boost] [array] compile-time checked access


I was just rewriting some old code with hard coded indices for array access and though that compile-time checked access to array elements would be a nice thing.
Maybe there are smart compilers out there that emit warnings or errors for a hard coded out-of-bounds access, but my compiler does not.

So, code like

compiles without warnings or erros.
Now, adding the following functions to array

would make it possible to write

which results in the expected error messages.


View this message in context:
Sent from the Boost - Dev mailing list archive at
Unsubscribe & other changes:

Boost list run by bdawes at, gregod at, cpdaniel at, john at