Why this warning from IBM XL C/C++ compiler?

后端 未结 4 1310
感情败类
感情败类 2021-01-12 07:38

Here\'s a minimum code example that illustrates the problem:

#include 

class Thing
{
   // Non-copyable
   Thing(const Thing&);
   Thing         


        
4条回答
  •  醉梦人生
    2021-01-12 08:09

    C++ permits sufficiently-smart compilers to avoid copying temporary objects, the one violation of the as-if rule allowed by the standard. I'm not familiar with IBM's AIX C++ compiler, but it sounds like it thinks the show(3) call requires a temporary Thing to be copied. In that case, C++ requires that you have an accessible copy constructor even though your compiler is smart enough to avoid using it.

    But why does show(3) require a copy in the first place? That I can't figure out. With luck, litb will be along in a bit.

提交回复
热议问题