[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Bug c++/24522] htonl in optimized template function generates compiler warning




------- Comment #4 from ckillian at cs dot ucsd dot edu  2005-10-25 17:09 -------
(In reply to comment #3)
> I believe this winds up being a duplicate of PR c++/8057, which is fixed on
> mainline.  With the test case in the PR, I see the warning with 4.0, but I do
> not see the warning on mainline.
> 
> Note that this slightly modified test case:
> 
> #include <netinet/in.h>
> 
> template<typename S>
> void serialize(const uint32_t* pitem, const S& item) {
>   uint32_t t2 = htonl(item);
> }
> 
> template void serialize<int> (const uint32_t*, const int&);
> 
> issues a warning on both 4.0 and mainline:
> 
> foo.cc: In function ?void serialize(const uint32_t*, const S&) [with S = int]?:
> foo.cc:8:   instantiated from here
> foo.cc:5: warning: unused variable ?t2?
> 

The unused variable warning of course is behavior as expected for this small
sample.  My original statement that the sample should compile without warning
should seems not to be correct.  That could be corrected by using the variable,
for example by printing it.  The motivating example appended the bytes of t2 to
a std::string which was passed in by reference.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24522

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.



Reply to: