1

I'm trying to track down the source of this large warning in a big code base:

C:\Program Files (x86)\Microsoft Visual Studio 12.\VC\INCLUDE\xmemory0(592) : 
warning C4503: 
'std::_Tree<std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,false>>::_Insert_at' : decorated name length exceeded, name was truncated
        with
        [
            _Kty=epmem_node_id,
            _Ty=std::map<std::string,std::list<std::string,std::allocator<std::string>>,std::less<std::string>,std::allocator<std::pair<const std::string,std::list<std::string,std::allocator<std::string>>>>>,
            _Pr=std::less<epmem_node_id>,
            _Alloc=std::allocator<std::pair<const epmem_node_id,std::map<std::string,std::list<std::string,std::allocator<std::string>>,std::less<std::string>, std::allocator<std::pair<const std::string,std::list<std::string,std::allocator<std::string>>>>>>>
        ]

I am planning on putting in the following to silence it:

#pragma warning(push)
#pragma warning(disable:4503)
... code here
#pragma warning(pop)

However, I keep putting this in the code base and the warning still pops up. The warning, unfortunately, does not specify what line, file or even class or variable the problem is found in, so I am completely lost. I tried using dumpbin /ALL, but when I searched the file I did not find _Tree anywhere.

How can I locate the source of this warning in my code base?

Nate Glenn
  • 6,455
  • 8
  • 52
  • 95
  • Is that the *complete* error log output? There's nothing more indicating where in your code the problem is? – Some programmer dude Mar 05 '15 at 11:21
  • Possibly some statment like: `map_obj[string_obj] = list_obj;` – Mohit Jain Mar 05 '15 at 11:23
  • Where to put the #pragma is very unintuitive in the case of templates, template expansion happens very late. It works when you put it at the *end* of the source code file :) – Hans Passant Mar 05 '15 at 11:32
  • @JoachimPileborg Yep, that's the complete log. No indication of location. – Nate Glenn Mar 05 '15 at 11:33
  • @MohitJain There are lots and lots of those, and I don't know which one causes the error. I'm dealing with a fairly large project. – Nate Glenn Mar 05 '15 at 11:33
  • @HansPassant So if there's a file with maps that cause the problem I put the pragma at the end? Then how do I pop the setting so that it doesn't apply to everything in the entire project? – Nate Glenn Mar 05 '15 at 11:35
  • 1
    There is of course nothing to pop when it is at the very end of the .cpp file. Nor can that affect any other file in your project. Makes it easy, doesn't it :) – Hans Passant Mar 05 '15 at 11:37
  • Oh, I see, thank you: http://stackoverflow.com/questions/5078679/what-is-the-scope-of-a-pragma-directive That solves my problem, not sure if I should leave the question open for a more general answer or just reword the question and use your answer. – Nate Glenn Mar 05 '15 at 11:40
  • Just post your own answer, show us what worked for you. – Hans Passant Mar 05 '15 at 11:57
  • This is one of the few warnings which I actually consider useless clutter, and hence disable mercilessly. – Angew is no longer proud of SO Mar 05 '15 at 12:28

1 Answers1

2

My question was how to find which line of code is causing the problem, but that wouldn't actually solve my problem. Since the offending code involves templating, the decorated name which cl warns about is generated after the rest of the code in the translation unit is processed, and so I would not be able to surround any given piece of code with a warnings(push)/warning(pop) pair.

The solution for me was to put #pragma warning(disable:4503) at the end of the file (I put it just before the #endif of the include guard). This silences the warning for all decorated names generated from structures in the file which use tempaltes. The scope of a warning(...) pragma is just to the current translation unit, so this doesn't affect any other files.

Nate Glenn
  • 6,455
  • 8
  • 52
  • 95