Q. on pointer/integer comparison

With -std=c++11, clang will complain about the expression in
bar() but not foo().

    bool foo(int *p) { return (p != 0); }
    bool bar(int* p) { return (p != (1 - 1)); }

With -std=c++03, clang accepts both.

[expr.const]p3 has a Note that says an integral constant expression
can be used as a null pointer constant.
So, I think Clang should accept both even in C++11 mode.

Bug, or my usual confusion about the standard? (I can see issuing
a warning, because it would be hard to contrive a real-world case
where somebody would actually want to do this; but if it conforms,
Clang should not reject it.)

Thanks,
--paulr

This was changed by DR 903:

  C++ Standard Core Language Defect Reports and Accepted Issues

We implement this DR in C++11 onwards, since the C++98 rules are *really*
broken when combined with C++11's generalized constant expressions. Without
this change, ridiculous things like

  struct S { int n; };
  int *p = S().n;

... would compile, because S().n is an integral constant expression with
value 0.

Cool. Although I have to wonder if there’s a consolidated 2011-as-amended document,

or do I have to cruise the defects page every time I’m trying to look something up?

Thanks,

–paulr

Cool. Although I have to wonder if there's a consolidated
2011-as-amended document,

or do I have to cruise the defects page every time I'm trying to look
something up?

Sorry, there's no such thing for C++11. I'm going to try to maintain such
an amended document for C++14, time permitting.