epics-base / pvDataCPP

pvDataCPP is an EPICS V4 C++ module
https://epics-base.github.io/pvDataCPP/
Other
6 stars 16 forks source link

Disable warning 4344 for Windows targets #41

Closed dhickin closed 8 years ago

dhickin commented 8 years ago

On Windows every call of the template getSubField (or the throwing getSubFieldT) leads to a level 1 build warning (4344), e.g.

"warning C4344: behavior change: use of explicit template arguments results in call to 'std::tr1::shared_ptr<_Ty> epics::pvData::PVStructure::getSubField Tepics::pvData::PVInt(const char *) const' with [ _Ty=epics::pvData::PVInt ] but the regular function 'epics::pvData::PVFieldPtr epics::pvData::PVStructure::getSubFieldT (const std::string &) const' is a better match if you expect 'epics::pvData::PVFieldPtr epics::pvData::PVStructure::getSubFieldT(const std: :string &) const' to be called then you need to make it an explicit specialization"

This seems to me a very stupid warning: You explicitly tell the compiler you want to call the template function and the compiler tells that if you hadn't explicitly told it to call the template function it would have called the non-template. No other compiler warns about this.

I'd like disable this warning as it generates a very noisy message in every bit of code that calls a template getSubField[T] and the thing being warned about is not an issue.

dhickin commented 8 years ago

I'm aware of undesirability of turning this off in the header without push/pop. However, as you say push/pop won't work (I did consider this).

I considered disabling with /wd4344 too, but as far as I know that would require each module to have this fix as well as any library or application, current or future, which uses pvData. So anyone writing their first application will see likely this.

Would setting the flag in base propagate to other modules? It wouldn't solve the issue for people building against old bases though, which they will be doing for a while.

The warning message is a mess. Apart from giving an unprofessional appearance, it makes finding a genuine error in the output harder.

I can't think of any good reason for the warning. I suspect "behavior change" means old versions of Microsoft compilers did the wrong thing. So now the compiler does the right thing it warns you that the compiler behaviour has changed (from wrong to right).

I don't know how far back we would have to go to get the old behaviour (warning 4350 references Visual C++ .NET 2002).

anjohnson commented 8 years ago

The change to the compiler flags in the build system was applied to all Base branches (3.14 on 2016-08-17, 3.15 on 2016-09-02 and 3.16 on 2016-09-07), thus this fix is no longer required.