我们正在迁移到 Sun Studio 12.1 和新的编译器 [CC: Sun C++ 5.10 SunOS_sparc 2009/06/03]。我在编译使用早期版本的 Sun 编译器 [CC: Sun WorkShop 6 update 2 C++ 5.3 2001/05/15] 编译良好的代码时遇到编译错误。
这是我得到的编译错误。
“Sample.cc”:错误:找不到 main() 中所需的 LoopThrough(int[2]) 的匹配项。1 检测到错误。*** 错误代码 1。
代码:
#include <iostream> 
#define PRINT_TRACE(STR) \
std::cout << __FILE__ << ":" << __LINE__ << ":" << STR << "\n";
template<size_t SZ>
void LoopThrough(const int(&Item)[SZ])
{
    PRINT_TRACE("Specialized version");
    for (size_t index = 0; index < SZ; ++index)
    {
        std::cout << Item[index] << "\n";
    }
}
/*     
    template<typename Type, size_t SZ>
    void LoopThrough(const Type(&Item)[SZ])
    {
        PRINT_TRACE("Generic version");        
    }
 */  
int main()
{
    {
       int arr[] = { 1, 2 };
       LoopThrough(arr);    
    }
}
如果我用通用版本取消注释代码,代码编译得很好并且通用版本被调用。在禁用扩展的 MSVC 2010 和这里的 ideone 情况下,我没有看到这个问题。调用该函数的专用版本。现在的问题是,这是 Sun Compiler 中的错误吗?
如果是,我们如何提交错误报告?