Skip to content

Incorrect output for template code #365

@IOBYTE

Description

@IOBYTE

This code:

template<long Len = 128, long BlockSize = 128, class T = wchar_t>
class String {
public:
  bool Format(const wchar_t FormatStr[], ...) { return true; }
};

void FTest() {
  double d{};

  String s;
  s.Format(L"%i", d);
}

produced this output:

template<long Len = 128, long BlockSize = 128, class T = wchar_t>
class S

/* First instantiated from: insights.cpp:10 */
#ifdef INSIGHTS_USE_TEMPLATE
template<>
String -> String<128, 128, wchar_t>;
#endif
tring {
public:
  bool Format(const wchar_t FormatStr[], ...) { return true; }
};

/* First instantiated from: insights.cpp:10 */
#ifdef INSIGHTS_USE_TEMPLATE
template<>
class String<128, 128, wchar_t>
{
  
  public: 
  inline bool Format(const wchar_t * FormatStr, ...)
  {
    return true;
  }
  
  // inline constexpr String() noexcept = default;
};

#endif


void FTest()
{
  double d = {};
  String<128, 128, wchar_t> s = String<128, 128, wchar_t>();
  s.Format(L"%i", d);
}

The first instantiation was inserted in the middle of the class name on line 2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions