Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

Intel(R) C++ 11.1.051 gives Warning warning #1684: conversion from pointer to same-sized integral type (potential portability problem)

brnprasad630
Beginner
557 Views
Hi All,

I am working on a project where we are using Intel C++ 11.1.051 compiler to comple a VC++ application. This application is being ported from 32bit Windows OS to 64bit Win7 os.

If I build the application using visual C++ compiler with the project option /Wp64 for detecting 64bit portability issues it is building the application properly with out any warnings/errors.

But when i use the intel compiler and use the project option /Wp64 for detecting 64bit portability issues it is showing the

"Warning warning #1684: conversion from pointer to same-sized integral type (potential portability problem)".

This error while using the

#define pcOffset(member) offsetof(PrimaryCmdStruct, member)

offsetof is the macro definition in the header file stddef.h.

In our code we care using DWORD_PTR for accressing the address being returned by the pcOffset definition.
I tried in many ways to fix it but in vain.

I am not finding any issues in 32-bit system.

If anybody found this problem before please suggest me how to go about this issue.

Thanks in advance,
BRN Prasad.

0 Kudos
4 Replies
Aubrey_W_
New Contributor I
557 Views

I have moved this from the 64-Bit Programming forum. I'm sure we can get an answer for you here.

==
Aubrey W.
Intel Software Network Support

0 Kudos
TimP
Honored Contributor III
557 Views
Any cast from pointer to an int type invokes potential portability problems, so you can expect each compiler to take a different default attitude toward associated warnings. The option /Wp64 seems to have worn out its welcome, now that most people who are willing to consider 64-bit mode have completed their efforts, so it isn't getting so much consideration as to what it should flag. What is same-sized on one platform won't be on another. Some practioners are dead set on the Windows scheme that traditional int types don't change size between 32- and 64-bit mode, using Windows-specific macros to bridge over the differences, and others are dead set on as many int types as possible changing from 32- to 64-bit in accordance with target mode. Certain OS vendors buck the trends advocated by standard C since more than a decade ago, and others go with the consensus of the compiler developers.
It's a mystery why that 64-bit forum was started without even a post as to what the intention might have been, so long after most practitioners had made up their mind about their primary preferences.
0 Kudos
mecej4
Honored Contributor III
557 Views
Warnings are not errors; they indicate pieces of code that have the potential to cause errors later in time or in other environments.

A warning does not prevent completion of compilation. If you don't mind seeing the warnings flash on to the screen, just ignore them.

If the warnings you see are too numerous or painful to ignore, you can turn them off, either selectively or in toto by specifying suitable options to the compiler.
0 Kudos
jimdempseyatthecove
Honored Contributor III
557 Views
I think the problem arises from two areas:

stddef.h (older version) may use size_t instead of ptrdiff_t
some of the newercompilers treat NULL (0x0) differently than non-NULL

Try:

#undef offsetof
#define offsetof (str,mem) ((ptrdiff_t)&(reinterpret_cast(0x1000)->mem)- 0x1000)

#define pcOffset(member) offsetof(PrimaryCmdStruct, member)

Jim Dempsey
0 Kudos
Reply