Visual Studioのreinterpret_castは盛大にバグっている

まあタイトルで大体話が終わっているんですが

```cpp
int main() 
{ 
    int a = reinterpret_cast<int>(-1); 
}
```

こんなコードが通りません。

```
source.cpp(3): error C2440: 'reinterpret_cast' : cannot convert from 'int' to 'int'

Conversion is a valid standard conversion, which can be performed implicitly or by use of static_cast, C-style cast or function-style cast
```

こんなふうに言われます。

ところで本当にバグか不安なのでTwitterで聞いたところ

<blockquote class="twitter-tweet" data-lang="ja"><p lang="ja" dir="ltr"><a href="https://twitter.com/yumetodo">@yumetodo</a> §5.2.10 p2により整数型を自分自身の型にキャストすることは合法。</p>&mdash; Ryou Ezoe (@EzoeRyou) <a href="https://twitter.com/EzoeRyou/status/730256108812541952">2016年5月11日</a></blockquote>

ん？§5.2.10 p2ってなんだ

§5.2.10 p2

>The reinterpret_cast operator shall not cast away constness (5.2.11). **An expression of integral**, enumeration, pointer, or pointer-to-member **type can be explicitly converted to its own type**; such a cast yields the value of its operand.

これか。

そんなわけでバグレポ投げました

https://connect.microsoft.com/VisualStudio/feedback/details/2692140/cannot-convert-integral-type-to-own-type-by-reinterpret-cast

# 追記

<blockquote class="twitter-tweet" data-conversation="none" data-lang="ja"><p lang="ja" dir="ltr"><a href="https://twitter.com/EzoeRyou">@EzoeRyou</a> <a href="https://twitter.com/yumetodo">@yumetodo</a> C++03 の規定に従えばエラーにする必要があったところで、それはおかしいということで C++11 で同じ型への変換を許すように改良されてました。<a href="https://t.co/fxHwMopTmO">https://t.co/fxHwMopTmO</a><br>MSVC がこれに対応できていないようです。</p>&mdash; Kazutoshi SATODA (@k_satoda) <a href="https://twitter.com/k_satoda/status/730801212212187140">2016年5月12日</a></blockquote>

なんだって！？

>http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3086.html#UK55

>
| ID          | Ref        | Comment                                                                                                                                                                                           | Proposed Resolution                                                                                                                                                                                    | Owner | Issue                                                               | Disposition                                                                                                                                                                                                                                                                         |
|-------------|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------|---------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| UK 55,[236] | 5.2.10,¶,2 | dynamic_cast and reinterpret_cast,crossreference 5.2.11 without creating an extra note. The,second half of the note is unrelated to the crossrefernce,,and would serve as well in normative text. | Strike the note,about definition of casting away constness, preserve the,cross-reference. The second sentance on reintrepret_cast to,its own type should move out of the note into the normative,text. | CWG   | [799](http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_toc.html#799) | ACCEPTED,The repetition of the reference to 5.2.11 was handled as a quasi-editorialchange in paper N2841.,Issue 799 was opened for the question about castingto the same type as the operand.,See paper,[N2841](http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2841.html) |

たしかにイギリスからNational Body commentsとして出ていて、

>http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#799
>799. Can reinterpret_cast be used to cast an operand to its own type?
Section: 5.2.10  [expr.reinterpret.cast]     Status: CD2     Submitter: UK     Date: 3 March, 2009

>[N2800 comment UK 55](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3086.html#UK55)

>[Voted into WP at March, 2010 meeting.]

>The note in 5.2.10 [expr.reinterpret.cast] paragraph 2 says,

>    Subject to the restrictions in this section, an expression may be cast to its own type using a ``reinterpret_cast`` operator. 

>However, there is nothing in the normative text that permits this conversion, and paragraph 1 forbids any conversion not explicitly permitted.

>(See also [issue 944](http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#944).)

>Proposed resolution (October, 2009):

>1. Change 5.2.10 [expr.reinterpret.cast] paragraph 2 as follows:  
>>The ``reinterpret_cast`` operator shall not cast away constness (5.2.11 [expr.const.cast]). ~~[Note: Subject to the restrictions in this section, an expression may be cast to its own type using a ``reinterpret_cast`` operator. —end note]~~ **An expression of integral, enumeration, pointer, or pointer-to-member type can be explictly converted to its own type; such a cast yields the value of its operand.** 

>2. Change 5.2.10 [expr.reinterpret.cast] paragraph 10 as follows:
>>An rvalue of type “pointer to member of ``X`` of type ``T1``” can be explicitly converted to an rvalue of **a different type** “pointer to member of ``Y`` of type ``T2``” if ``T1`` and ``T2`` are both function types or both object types... 

Core IssueとなりめでたくC++11で修正が入っているようだ。