Hacker News new | ask | show | jobs
by kevinastock 4312 days ago
Shouldn't it be 'float * restrict a'?

When could one get into trouble thinking that "restrict == this will not alias"? If X is never modified during B it seems like aliasing wouldn't cause any problems.

Since restrict means nothing if no value in it is modified, would it be reasonable and possible for the compiler to issue a warning in cases like example1?

2 comments

In this specific case you will get into trouble if you expect the compiler to be able to reorder loads, and it doesn't.

IE you will get into performance trouble :)

In general, there are some complicated scope related cases where you will get into trouble (the rules deal with "based on" and "scope" all over the place, and not in ways that always make sense).

I guess one could get in trouble if you were writing a compiler, as users could write conforming code that you thought was undefined.

I don't see how one could get into trouble as a developer though. It seems to me that, while technically incorrect, the blog imposes more restrictions than is actually neccessary on the user.