public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/24522] New: htonl in optimized template function generates compiler warning
@ 2005-10-25 16:24 ckillian at cs dot ucsd dot edu
2005-10-25 16:26 ` [Bug c++/24522] " ckillian at cs dot ucsd dot edu
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: ckillian at cs dot ucsd dot edu @ 2005-10-25 16:24 UTC (permalink / raw)
To: gcc-bugs
Overview Description: More detailed expansion of summary.
When compiling template functions in g++ 4.0.2 (Debian 4.0.2-2) (Debian
testing/unstable) with -O2 and -Wall, the compiler generates a warning about a
statement with no effect. This seems to be due to the inlining with __v; as a
statement, but the warning does not occur in non-template functions or with
other compiler versions tried (3.4).
Steps to Reproduce: Minimized, easy-to-follow steps that will trigger the
bug. Include any special setup steps.
1) Create the following .cc file (as test.cc):
#include <netinet/in.h>
template<typename S>
void serialize(const uint32_t* pitem, const S& item) {
uint32_t t2 = htonl(item);
}
2) Compile "test.cc"
$ g++ -O2 -Wall -c -o test.o test.cc
Actual Results: What the application did after performing the above steps.
g++ generated a warning that the htonl statement has no effect.
$ g++ -O2 -Wall -c -o test.o test.cc
test.cc: In function 'void serialize(const uint32_t*, const S&)':
test.cc:5: warning: statement has no effect
Expected Results: What the application should have done, were the bug not
present.
test.o should have been created without warning
Build Date & Platform: Date and platform of the build that you first
encountered the bug in.
>Release: 4.0.2 (Debian 4.0.2-2) (Debian testing/unstable)
configured with: ../src/configure -v
--enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr
--enable-shared --with-system-zlib
--libexecdir=/usr/lib--without-included-gettext --enable-threads=posix
--enable-nls --program-suffix=-4.0 --enable-__cxa_atexit
--enable-libstdcxx-allocator=mt --enable-clocale=gnu--enable-libstdcxx-debug
--enable-java-gc=boehm --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr
--disable-werror --enable-checking=release i486-linux-gnu
>Environment:
System: Linux killian.ucsd.edu 2.6.12.20051019-ck1 #1 SMP Wed Oct 19 09:24:47
PDT 2005 i686 GNU/Linux
Architecture: i686
Additional Builds and Platforms: Whether or not the bug takes place on
other platforms (or browsers, if applicable).
- Also Occurs On
Unknown
- Doesn't Occur On
g++ version 3.4.4 20050721 (Red Hat 3.4.4-2)
Or without -O2, -Wall, or outside of a template function.
--
Summary: htonl in optimized template function generates compiler
warning
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ckillian at cs dot ucsd dot edu
GCC build triplet: i486-pc-linux-gnu
GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24522
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/24522] htonl in optimized template function generates compiler warning
2005-10-25 16:24 [Bug c++/24522] New: htonl in optimized template function generates compiler warning ckillian at cs dot ucsd dot edu
2005-10-25 16:26 ` [Bug c++/24522] " ckillian at cs dot ucsd dot edu
@ 2005-10-25 16:26 ` ckillian at cs dot ucsd dot edu
2005-10-25 16:36 ` ian at airs dot com
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ckillian at cs dot ucsd dot edu @ 2005-10-25 16:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from ckillian at cs dot ucsd dot edu 2005-10-25 16:26 -------
Created an attachment (id=10056)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10056&action=view)
preprocessor output
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24522
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/24522] htonl in optimized template function generates compiler warning
2005-10-25 16:24 [Bug c++/24522] New: htonl in optimized template function generates compiler warning ckillian at cs dot ucsd dot edu
@ 2005-10-25 16:26 ` ckillian at cs dot ucsd dot edu
2005-10-25 16:26 ` ckillian at cs dot ucsd dot edu
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ckillian at cs dot ucsd dot edu @ 2005-10-25 16:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from ckillian at cs dot ucsd dot edu 2005-10-25 16:26 -------
Created an attachment (id=10055)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10055&action=view)
The test.cc file
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24522
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/24522] htonl in optimized template function generates compiler warning
2005-10-25 16:24 [Bug c++/24522] New: htonl in optimized template function generates compiler warning ckillian at cs dot ucsd dot edu
2005-10-25 16:26 ` [Bug c++/24522] " ckillian at cs dot ucsd dot edu
2005-10-25 16:26 ` ckillian at cs dot ucsd dot edu
@ 2005-10-25 16:36 ` ian at airs dot com
2005-10-25 17:09 ` ckillian at cs dot ucsd dot edu
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ian at airs dot com @ 2005-10-25 16:36 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1048 bytes --]
------- Comment #3 from ian at airs dot com 2005-10-25 16:36 -------
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
--
ian at airs dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ian at airs dot com
Known to work| |4.1.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24522
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/24522] htonl in optimized template function generates compiler warning
2005-10-25 16:24 [Bug c++/24522] New: htonl in optimized template function generates compiler warning ckillian at cs dot ucsd dot edu
` (2 preceding siblings ...)
2005-10-25 16:36 ` ian at airs dot com
@ 2005-10-25 17:09 ` ckillian at cs dot ucsd dot edu
2005-10-25 17:51 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ckillian at cs dot ucsd dot edu @ 2005-10-25 17:09 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1205 bytes --]
------- 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/24522] htonl in optimized template function generates compiler warning
2005-10-25 16:24 [Bug c++/24522] New: htonl in optimized template function generates compiler warning ckillian at cs dot ucsd dot edu
` (3 preceding siblings ...)
2005-10-25 17:09 ` ckillian at cs dot ucsd dot edu
@ 2005-10-25 17:51 ` pinskia at gcc dot gnu dot org
2005-10-25 17:59 ` [Bug c++/24522] [4.0 Regression] " pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-25 17:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from pinskia at gcc dot gnu dot org 2005-10-25 17:51 -------
Here is a reduced testcase:
template <int >
void f(int i)
{
int i1 = (__extension__ ({int i2 = i; i2;}));
}
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Known to work|4.1.0 |4.1.0 3.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24522
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/24522] [4.0 Regression] htonl in optimized template function generates compiler warning
2005-10-25 16:24 [Bug c++/24522] New: htonl in optimized template function generates compiler warning ckillian at cs dot ucsd dot edu
` (4 preceding siblings ...)
2005-10-25 17:51 ` pinskia at gcc dot gnu dot org
@ 2005-10-25 17:59 ` pinskia at gcc dot gnu dot org
2006-03-11 3:20 ` mmitchel at gcc dot gnu dot org
2007-02-03 15:49 ` gdr at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-25 17:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pinskia at gcc dot gnu dot org 2005-10-25 17:59 -------
(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.
I don't think this is a duplicate of PR 8057 because my reduced testcase worked
in 3.4.5. I think this was introduced by one of the C++ patches between 4.0.1
and 4.0.2
> Or without -O2, -Wall, or outside of a template function.
the without -O2, is because the headers change, which is why my simplified
example shows the issue at every optimization level.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
GCC build triplet|i486-pc-linux-gnu |
GCC host triplet|i486-pc-linux-gnu |
GCC target triplet|i486-pc-linux-gnu |
Known to fail| |4.0.3
Known to work|4.1.0 3.4.0 |4.1.0 3.4.0 3.4.5
Last reconfirmed|0000-00-00 00:00:00 |2005-10-25 17:59:02
date| |
Summary|htonl in optimized template |[4.0 Regression] htonl in
|function generates compiler |optimized template function
|warning |generates compiler warning
Target Milestone|--- |4.0.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24522
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/24522] [4.0 Regression] htonl in optimized template function generates compiler warning
2005-10-25 16:24 [Bug c++/24522] New: htonl in optimized template function generates compiler warning ckillian at cs dot ucsd dot edu
` (5 preceding siblings ...)
2005-10-25 17:59 ` [Bug c++/24522] [4.0 Regression] " pinskia at gcc dot gnu dot org
@ 2006-03-11 3:20 ` mmitchel at gcc dot gnu dot org
2007-02-03 15:49 ` gdr at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-03-11 3:20 UTC (permalink / raw)
To: gcc-bugs
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.0.3 |4.0.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24522
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/24522] [4.0 Regression] htonl in optimized template function generates compiler warning
2005-10-25 16:24 [Bug c++/24522] New: htonl in optimized template function generates compiler warning ckillian at cs dot ucsd dot edu
` (6 preceding siblings ...)
2006-03-11 3:20 ` mmitchel at gcc dot gnu dot org
@ 2007-02-03 15:49 ` gdr at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: gdr at gcc dot gnu dot org @ 2007-02-03 15:49 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from gdr at gcc dot gnu dot org 2007-02-03 15:48 -------
Fixed in GCC-4.1.0 and higher
--
gdr at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|4.0.4 |4.1.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24522
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2007-02-03 15:49 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-25 16:24 [Bug c++/24522] New: htonl in optimized template function generates compiler warning ckillian at cs dot ucsd dot edu
2005-10-25 16:26 ` [Bug c++/24522] " ckillian at cs dot ucsd dot edu
2005-10-25 16:26 ` ckillian at cs dot ucsd dot edu
2005-10-25 16:36 ` ian at airs dot com
2005-10-25 17:09 ` ckillian at cs dot ucsd dot edu
2005-10-25 17:51 ` pinskia at gcc dot gnu dot org
2005-10-25 17:59 ` [Bug c++/24522] [4.0 Regression] " pinskia at gcc dot gnu dot org
2006-03-11 3:20 ` mmitchel at gcc dot gnu dot org
2007-02-03 15:49 ` gdr at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).