[gcc 4.1.1] -O2 warning: std::temporary_buffer dereferences type-punned pointer -------------------------------------------------------------------------------
Key: STDCXX-350 URL: https://issues.apache.org/jira/browse/STDCXX-350 Project: C++ Standard Library Issue Type: Bug Components: 20. General Utilities Affects Versions: 4.1.3, 4.1.4 Environment: gcc 4.1.1 -O2, Solaris 10 Reporter: Martin Sebor Compiling the following program with gcc 4.1.1 on Solaris 10 produces the warning below: $ cat t.cpp && gmake -r t #include <memory> int main () { std::get_temporary_buffer<int>(1); } gcc -c -I/amd/devco/sebor/stdcxx/include/ansi -pthreads -I/amd/devco/sebor/stdcxx/include -I/build/sebor/gcc-4.1.1-12d/include -I/amd/devco/sebor/stdcxx/examples/include -pedantic -nostdinc++ -O2 -W -Wall -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long t.cpp /amd/devco/sebor/stdcxx/include/rw/_rawiter.h: In function 'std::pair<_TypeT*, _Distance> std::get_temporary_buffer(_Distance, _TypeT*) [with _TypeT = int, _Distance = int]': /amd/devco/sebor/stdcxx/include/rw/_rawiter.h:146: instantiated from 'std::pair<_TypeT*, int> std::get_temporary_buffer(int) [with _TypeT = int]' t.cpp:5: instantiated from here /amd/devco/sebor/stdcxx/include/rw/_rawiter.h:131: warning: dereferencing type-punned pointer will break strict-aliasing rules gcc t.o -o t -pthreads -L/build/sebor/gcc-4.1.1-12d/lib -lstd12d -Wl,-R/build/sebor/gcc-4.1.1-12d/lib -lsupc++ -lm rm t.o -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.