标签: solaris-studio

C++预处理器删除对可变参数宏的调用中的空白(Solaris Studio 12.3)

Oracle Solaris Studio 12.3的C++预处理器在扩展时会完全删除空白__VA_ARGS__.

有人可以在他们的系统上确认这种行为吗?它是一个已知的编译器错误吗?这个问题有没有解决方法?

为了说明,这是一个简单的测试程序,vaargs.c:

#include <stdio.h>

#define PRINT(...) printf("%s\n", #__VA_ARGS__)

int main()
{
    PRINT(hello world);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

C预处理器按预期工作:

$ cc vaargs.c -o vaargs && ./vaargs
hello world

$ cc -V
cc: Sun C 5.12 SunOS_i386 2011/11/16
Run Code Online (Sandbox Code Playgroud)

但是C++预处理器删除了"hello"和"world"之间的空格:

$ CC vaargs.c -o vaargs && ./vaargs
helloworld

$ CC -V
CC: Sun C++ 5.12 SunOS_i386 2011/11/16
Run Code Online (Sandbox Code Playgroud)

c++ solaris c-preprocessor variadic-macros solaris-studio

11
推荐指数
1
解决办法
561
查看次数

这是Solaris Studio中的一个错误的错误吗?

源代码(在问题的最后)将引发我认为是Solaris Studio上的错误错误(而不是其他编译器).

为清楚起见,使用新行重新格式化了错误消息:

"overload.cpp", line 44: Error:
runGenEntries<std::vector<int>>(const GenEntryRuleDriven<int>&, const std::vector<int>&)
and
runGenEntries<std::vector<int>>(const GenEntryRulesDriven<int>&, const std::vector<int>&)
have same extern name
"__1cNrunGenEntries4nDstdGvector4Cin0AJallocator4Ci_____6FrkTArk1_v_".
1 Error(s) detected.
Run Code Online (Sandbox Code Playgroud)

注意两个函数runGenEntries的第一个参数如何只有一个字符(规则末尾的's')

当第一个参数是类型时,似乎会发生这种情况:

const typename GenEntryRulesDrivenType<typename InputsType::value_type>::type
Run Code Online (Sandbox Code Playgroud)

并且当第一个参数而不是类型时不会发生:

const typename GenEntryRulesDriven<typename InputsType::value_type>
Run Code Online (Sandbox Code Playgroud)

最终解决了相同的类型!

这是仅在Solaris上实现的一些模糊的C++规则的结果吗?或者,当它破坏符号时,这是一个Solaris Studio错误吗?

完整的来源

以下源代码可以在任何编译器上编译.

定义将激活引发错误的代码,或者激活应该产生相同结果的代码(但这次没有错误):

#include <iostream>
#include <vector>

template<typename T>
struct GenEntryRulesDriven
{
   void foo() const
   {
   }
};

template<typename T>
struct GenEntryRuleDriven
{
   void bar() const
   {
   }
   std::string toto; // to have a different size than GenEntryRulesDriven
};


template <typename T> …
Run Code Online (Sandbox Code Playgroud)

c++ solaris name-mangling solaris-studio

5
推荐指数
1
解决办法
417
查看次数

Sun Studio和"",第1行:非法旗帜( - )

我试图"", line 1 : Illegal flag (-)在Sun Studio 12.3下追踪在Solaris 11.3(x64)上产生汇编错误的问题.Sun Studio编译器是一种特殊的地狱.

$ echo $CXX
/opt/solarisstudio12.3/bin/CC

$ cat test.cxx
#include <iostream>
int main(int argc, char* argv[])
{
  std::cout << argc << std::endl;
  return 0;
}

$ $CXX -DNDEBUG -xO2 -native -template=no%extdef -m64 -Kpic -Wa,--divide -c test.cxx
Assembler: 
        "", line 1 : Illegal flag (-)
CC: fbe failed for test.cxx
Run Code Online (Sandbox Code Playgroud)

系统移除-xO2,-native,-m64,-Kpic,等...不能解决它.我在Mozilla发现了一个类似的报告,但删除调试符号并没有解决它.

汇编程序文件的第一行是.file ...(如下所示),因此我不清楚非法标志的来源.

我为什么要体验"", line …

c++ solaris solaris-studio

0
推荐指数
1
解决办法
143
查看次数