Search
Closed
as Won't Fix Help for as Won't Fix

1
Sign in to vote
0
Sign in to vote
Sign in
to vote
Type: Bug
ID: 460427
Opened: 5/28/2009 6:38:24 PM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
template宣言におけるtypenameの扱いが曖昧である。
template<typename int>
はエラーになるべきであるが、コンパイル時にエラー・警告が出ない。
また、template宣言中であれば以下の様な構文でもエラーにならない。
template<typename int> void foo(typename int n) {}
更にtypenameを多重に宣言してもエラーとはならない。
teplate<typename typename typename T> class bar {}

他のC++コンパイラではエラーとなるので可搬性に欠けるプログラムが作られてしまう可能性がある。
Details (expand)
製品言語
日本語
バージョン
Visual Studio 2008
オペレーティング システム
Windows Vista
オペレーティング システム言語
日本語
再現の手順
以下に示すコードを含んだプログラムをコンパイルする。
template<typename int n> struct st1 {
int v;
st1() : v(n) {}
};
template<typename typename int n> struct st2 {
int v;
st2() : v(n) {}
};
template<typename typename T> void func1(typename typename typename typename typename int a) {}
template<typename class T> void func2(typename typename typename typename typename int a) {}
実際の結果
コンパイルエラー・警告は出力されず正常にコンパイルが終わる。
期待した結果
不適切なtypenameの使用なのでエラーが出力される。
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 5/31/2009 at 6:31 PM

この度は、フィードバックをお送りいただき、誠にありがとうございます。 現在、お送りいただきました報告内容に基づき問題を調査中ですので、しばらくお待ちください。 よろしくお願いいたします。

[Problem Description]
The behavior of typename is unclear in the template declaration. Although template<typename int> should result in an error, no error or warning appears at compile time. In addition, the following syntax is not considered as an error in the template declaration:
template<typename int> void foo(typename int n) {}

Furthermore, no error occurs when typename is multiply declared:
teplate<typename typename typename T> class bar {}

Since other C++ compilers consider them as an error, there’s a possibility that a non-portable program may be created.

[Repro Steps]
Compile a program that includes the code described below.

template<typename int n> struct st1 {
int v;
st1() : v(n) {}
};
template<typename typename int n> struct st2 {
int v;
st2() : v(n) {}
};
template<typename typename T> void func1(typename typename typename typename typename int a) {}
template<typename class T> void func2(typename typename typename typename typename int a) {}

[Actual Results]
Compile completes successfully without any compile error or warning.

[Expected Results]
An error appears since typename is inappropriately used.

Posted by Microsoft on 6/2/2009 at 2:43 AM
Thanks for your feedback. We are escalating this bug to the product unit who works on that specific feature area. The team will review this issue and make a decision on whether they will fix it or not for the next release.

Thank you,
Visual Studio Product Team
Posted by Microsoft on 6/2/2009 at 5:41 PM

(こちらは、Posted by Microsoft on 6/2/2009 at 2:43 AM の和訳です。)

この度は、フィードバックをお送りいただき、誠にありがとうございます。 こちらのバグに関しましては、該当する機能を専門で担当している製品チームに報告させていただきます。 今後は、同チームが問題を再調査し、次期リリースでの修正について判断する予定です。 よろしくお願いいたします。

Visual Studio 製品チーム

Posted by Microsoft on 6/9/2009 at 10:16 AM
Hi: I can confirm that this is a bug with Visual C++. Unfortunately it does not meet the triage bar for the current release of Visual C++ - but we will keep the issue in our database and we will look at it again during the development phase of a future release of Visual C++.

Jonathan Caves
Visual C++ Compiler Team
Posted by Microsoft on 6/9/2009 at 6:25 PM

(こちらは、[投稿者: Microsoft、投稿日時: 2009/06/09 10:16] の和訳です。)

こんにちは。 こちらの件に関しまして、私の方で Visual C++ のバグであることを確認しました。 しかし、残念ながらこの問題は、Visual C++ の現行リリース版での検討基準を満たしておりません。 私たちは、こちらの問題をデータベースに保管し、Visual C++ の将来リリース版を開発する段階で再度検討させていただく予定です。

Jonathan Caves
Visual C++ コンパイラ チーム