[
https://issues.apache.org/jira/browse/STDCXX-772?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12587454#action_12587454
]
Travis Vitek commented on STDCXX-772:
-------------------------------------
Looks like another bogus warning, or at the very least a warning about
something that we don't really have any control over. Here is a testcase.
.
{noformat}
namespace bug {
template <class _Arg, class _Result>
struct unary_function
{
typedef _Arg argument_type;
typedef _Result result_type;
};
template <class _Arg1, class _Arg2, class _Result>
struct binary_function
{
typedef _Arg1 first_argument_type;
typedef _Arg2 second_argument_type;
typedef _Result result_type;
};
template <class _TypeT>
struct minus : public binary_function<_TypeT, _TypeT, _TypeT>
{
typedef typename binary_function<_TypeT, _TypeT, _TypeT>::result_type
result_type;
typedef typename binary_function<_TypeT, _TypeT,
_TypeT>::first_argument_type first_argument_type;
typedef typename binary_function<_TypeT, _TypeT,
_TypeT>::second_argument_type second_argument_type;
result_type operator() (const first_argument_type& x,
const second_argument_type& y) const {
return x - y;
}
};
template <class _Operation>
struct binder1st : public unary_function<typename
_Operation::second_argument_type,
typename _Operation::result_type>
{
protected:
_Operation op;
typename _Operation::first_argument_type value;
public:
typedef typename _Operation::second_argument_type argument_type;
typedef typename _Operation::result_type result_type;
binder1st (const _Operation &oper,
const typename _Operation::first_argument_type& x)
: op (oper), value (x)
{
}
result_type operator() (const argument_type& y) const {
return op (value, y);
}
};
} // namespace bug
int ff (int);
int main ()
{
bug::minus<int> b;
bug::binder1st< bug::minus<int> > u (b, 1);
const int uu = u (0);
return ff (uu);
}
{noformat}
Here is the output when compiled with {{+O1}}
{noformat}
$ aCC -c -mt -AA -O1 +w u.cpp
"u.cpp", line 39: remark #4227-D: padding struct with 3 bytes to align member
"value"
typename _Operation::first_argument_type value;
^
detected during instantiation of class "bug::binder1st<_Operation>
[with _Operation=bug::minus<int>]" at line 63
"u.cpp", line 63: remark #2340-D: value copied to temporary, reference to
temporary used
bug::binder1st< bug::minus<int> > u (b, 1);
^
"u.cpp", line 65: remark #2340-D: value copied to temporary, reference to
temporary used
const int uu = u (0);
^
{noformat}
And here is the result when compiling with {{+O2}}
{noformat}
$ aCC -c -mt -AA +O2 +w u.cpp
"u.cpp", line 39: remark #4227-D: padding struct with 3 bytes to align member
"value"
typename _Operation::first_argument_type value;
^
detected during instantiation of class "bug::binder1st<_Operation>
[with _Operation=bug::minus<int>]" at line 63
"u.cpp", line 63: remark #2340-D: value copied to temporary, reference to
temporary used
bug::binder1st< bug::minus<int> > u (b, 1);
^
"u.cpp", line 65: remark #2340-D: value copied to temporary, reference to
temporary used
const int uu = u (0);
^
"u.cpp", line 48, procedure main: warning #20035-D: variable "b" is used
before its value is set
{noformat}
If we fold {{b}} into the definition of {{u}} like {{bug::binder1st<
bug::minus<int> > u (bug::minus<int>(), 1)}} the warning goes away. If we use a
local variable for {{1}} the warning goes away...
> [HP aCC 6.16] warning #20035-D: variable is used before its value is set in
> functional
> --------------------------------------------------------------------------------------
>
> Key: STDCXX-772
> URL: https://issues.apache.org/jira/browse/STDCXX-772
> Project: C++ Standard Library
> Issue Type: Sub-task
> Components: Tests
> Affects Versions: 4.2.0
> Environment: $ uname -sr && aCC -V
> HP-UX B.11.31
> aCC: HP C/aC++ B3910B A.06.16 [Nov 26 2007]
> Reporter: Scott (Yu) Zhong
> Assignee: Travis Vitek
> Fix For: 4.2.1
>
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> aCC -c -mt -I/amd/devco/scottz/stdcxx/4.2.x/include
> -I/build/scottz/12d/include -I/amd/devco/scottz/stdcxx/4.2.x/tests/include
> -AA +O2 +DD64
> +w +W392 +W655 +W684 +W818 +W819 +W849 +W2193 +W2236 +W2261 +W2340 +W2401
> +W2487 +W4227 +W4229 +W4231 +W4235 +W4237 +W4249 +W4255 +W4272 +W4284 +
> W4285 +W4286
> /amd/devco/scottz/stdcxx/4.2.x/tests/utilities/20.function.objects.cpp
> "/amd/devco/scottz/stdcxx/4.2.x/include/functional", line 320, procedure
> test_binders: warning #20035-D: variable "obj_minus" is used before its value
> is set
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.