Community
cancel
Showing results for 
Search instead for 
Did you mean: 
SergeyKostrov
Valued Contributor II
742 Views

Warning #1595: non-POD (Plain Old Data) class type passed through ellipsis - RESOLVED

Jump to solution

Please take a look at a Test-Case ( MFC Collections are used ):

...
CMapStringToString mS2S;
...
CString csKey = "";
CString csKeyValue = "";
...
POSITION pos = mS2S.GetStartPosition();
while( pos != NULL )
{
mS2S.GetNextAssoc( pos, csKey, csKeyValue );

printf( "\\tKey: %s\\tKey Value: %s\\n", csKey, csKeyValue );
}
...

../Common/PrtTests.cpp(28816): warning #1595: non-POD (Plain Old Data) class type passed through ellipsis
printf( "\\tKey: %s\\tKey Value: %s\\n", csKey, csKeyValue );
^

My questions are: What is 'non-POD'? What is wrong?

Development Environment:

OS: Windows XP 32-bit
IDE: Visual Studio 2005 SP1
Compilers: Intel C++ / Microsoft C++ / Borland C++ / MinGW / Turbo C++

Best regards,
Sergey

0 Kudos
1 Solution
Judith_W_Intel
Employee
742 Views
In section 5.2.2, paragraph 7, the C++ Standard says that it's undefined to pass objects of non-POD class types to the ellipsis. VC++ does not emit a diagnostic for this, and code such as the following compiles cleanly. This particular example produces several random characters in its output, while others may crash or malfunction in more subtle ways.

#include
#include

int main()
{
std::string s = "test";
printf("Without c_str(): %s\n", s);
}

A "POD" type is defined here:

http://stackoverflow.com/questions/146452/what-are-pod-types-in-c

Judy

View solution in original post

8 Replies
Om_S_Intel
Employee
742 Views

The POD is plane old data type object, eg int, float, double. It would be nice if you can provide complte test case to reproduce the issue. I could not reproduce the issue using the folloing test case.

c:\forum\U105042>type tst.cpp

// tst.cpp

#include

#include

int main()

{

CString csKey = "";

CString csKeyValue = "";

printf("\tKey: %s\tKey Value: %s\n", csKey, csKeyValue );

return 0;

}

c:\forum\U105042>icl tst.cpp

Intel C++ Compiler XE for applications running on IA-32, Version 12.1.1.258 Build 20111011

Copyright (C) 1985-2011 Intel Corporation. All rights reserved.

tst.cpp

_WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)

Microsoft Incremental Linker Version 10.00.40219.01

Copyright (C) Microsoft Corporation. All rights reserved.

-out:tst.exe

tst.obj

c:\forum\U105042>tst

Key: Key Value:

TimP
Black Belt
742 Views
The non-POD warning comes up frequently in the Boost build I'm working on. I've got more serious issues to deal with before I worry about that.
SergeyKostrov
Valued Contributor II
742 Views
...

The POD is plane old data type object, eg int, float, double. It would be nice if you can provide complte test case to reproduce the issue. I could not reproduce the issue using the folloing test case.
...
Your Test-Case is right.
...
c:\forum\U105042>icl tst.cpp

Please try to set a Warning Level 5.
...

SergeyKostrov
Valued Contributor II
742 Views
Quoting TimP (Intel)
...I've got more serious issues to deal with before I worry about that.


I need topay attention forevery issuebecause a project isdesigned for many platforms, including Embedded.

Judith_W_Intel
Employee
743 Views
In section 5.2.2, paragraph 7, the C++ Standard says that it's undefined to pass objects of non-POD class types to the ellipsis. VC++ does not emit a diagnostic for this, and code such as the following compiles cleanly. This particular example produces several random characters in its output, while others may crash or malfunction in more subtle ways.

#include
#include

int main()
{
std::string s = "test";
printf("Without c_str(): %s\n", s);
}

A "POD" type is defined here:

http://stackoverflow.com/questions/146452/what-are-pod-types-in-c

Judy

View solution in original post

SergeyKostrov
Valued Contributor II
742 Views
I know about that problem with STL 'string' class for many years and I always complain why it doesn't have
a C++ operator 'char *'?

Because, if the'string' classwould have it a code:

std::string s = "test";
printf( "Without c_str(): %s\n", s );

would be processed by a C++ compiler to:

std::string s = "test";
printf( "Without c_str(): %s\n", ( char * )s );

and, as you can see, there is noneed touse the'c_str' method.

Best regards,
Sergey
SergeyKostrov
Valued Contributor II
742 Views
Reply