[Bug c++/41874] Incorrect "dereferencing type-punned pointer will break strict-aliasing rules" warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874 Jason Merrill changed: What|Removed |Added Known to fail||6.5.0 CC||jason at gcc dot gnu.org Known to work||7.5.0 Target Milestone|--- |7.0 Status|REOPENED|RESOLVED Resolution|--- |FIXED --- Comment #17 from Jason Merrill --- (In reply to Aso Renji from comment #15) > No, this warning still appear if (and only if) you use -O2 or -O3 > optimization key (as it be in startpost with "g++ -O3 -Wstrict-aliasing > test.cc -o /dev/null" line). I don't see this with any compiler after 6.5.0.
[Bug c++/41874] Incorrect "dereferencing type-punned pointer will break strict-aliasing rules" warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874 Andrew Pinski changed: What|Removed |Added Target Milestone|4.5.0 |---
[Bug c++/94951] [8/9 Regression] dereferencing type-punned pointer will break strict-aliasing rules when using super class for a template type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94951 Andrew Pinski changed: What|Removed |Added CC||a-yee at u dot northwestern.edu --- Comment #12 from Andrew Pinski --- *** Bug 91343 has been marked as a duplicate of this bug. ***
[Bug c++/94951] [8/9 Regression] dereferencing type-punned pointer will break strict-aliasing rules when using super class for a template type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94951 Andrew Pinski changed: What|Removed |Added CC||rrrlasse at hotmail dot com --- Comment #11 from Andrew Pinski --- *** Bug 81152 has been marked as a duplicate of this bug. ***
[Bug c++/94951] [8/9 Regression] dereferencing type-punned pointer will break strict-aliasing rules when using super class for a template type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94951 Jakub Jelinek changed: What|Removed |Added Resolution|--- |FIXED Status|ASSIGNED|RESOLVED --- Comment #10 from Jakub Jelinek --- Fixed for 8.5 in r8-10503-g79a11b9833baa91cef7c881532e01470fa25047f and by the above commit for 9.4+ too.
[Bug c++/94951] [8/9 Regression] dereferencing type-punned pointer will break strict-aliasing rules when using super class for a template type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94951 --- Comment #9 from CVS Commits --- The releases/gcc-9 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:eca1dbea010ba4c18ccec90bacbad5d8ec72c09f commit r9-8897-geca1dbea010ba4c18ccec90bacbad5d8ec72c09f Author: Jakub Jelinek Date: Wed May 6 23:38:13 2020 +0200 c++: Avoid strict_aliasing_warning on dependent types or expressions [PR94951] The following testcase gets a bogus warning during build_base_path, when cp_build_indirect_ref* calls strict_aliasing_warning with a dependent expression. IMHO calling get_alias_set etc. on dependent types feels wrong to me, we should just defer the warnings in those cases until instantiation and only handle the cases where neither type nor expr are dependent. 2020-05-06 Jakub Jelinek PR c++/94951 * typeck.c (cp_strict_aliasing_warning): New function. (cp_build_indirect_ref_1, build_reinterpret_cast_1): Use it instead of strict_aliasing_warning. * g++.dg/warn/Wstrict-aliasing-bogus-tmpl.C: New test. (cherry picked from commit d82414ebcf7716ea24688510594a2c464a105908)
[Bug c++/94951] [8/9 Regression] dereferencing type-punned pointer will break strict-aliasing rules when using super class for a template type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94951 Jakub Jelinek changed: What|Removed |Added Summary|[8/9/10/11 Regression] |[8/9 Regression] |dereferencing type-punned |dereferencing type-punned |pointer will break |pointer will break |strict-aliasing rules when |strict-aliasing rules when |using super class for a |using super class for a |template type |template type --- Comment #8 from Jakub Jelinek --- Fixed for 10.2+ and 11+ so far.
[Bug c++/94951] [8/9/10/11 Regression] dereferencing type-punned pointer will break strict-aliasing rules when using super class for a template type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94951 --- Comment #7 from CVS Commits --- The releases/gcc-10 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:d82414ebcf7716ea24688510594a2c464a105908 commit r10-8115-gd82414ebcf7716ea24688510594a2c464a105908 Author: Jakub Jelinek Date: Wed May 6 23:38:13 2020 +0200 c++: Avoid strict_aliasing_warning on dependent types or expressions [PR94951] The following testcase gets a bogus warning during build_base_path, when cp_build_indirect_ref* calls strict_aliasing_warning with a dependent expression. IMHO calling get_alias_set etc. on dependent types feels wrong to me, we should just defer the warnings in those cases until instantiation and only handle the cases where neither type nor expr are dependent. 2020-05-06 Jakub Jelinek PR c++/94951 * typeck.c (cp_strict_aliasing_warning): New function. (cp_build_indirect_ref_1, build_reinterpret_cast_1): Use it instead of strict_aliasing_warning. * g++.dg/warn/Wstrict-aliasing-bogus-tmpl.C: New test.
[Bug c++/94951] [8/9/10/11 Regression] dereferencing type-punned pointer will break strict-aliasing rules when using super class for a template type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94951 --- Comment #6 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:46fcef99f49cc2d9f28d98f8ecdbf8263e9e0a87 commit r11-153-g46fcef99f49cc2d9f28d98f8ecdbf8263e9e0a87 Author: Jakub Jelinek Date: Wed May 6 23:38:13 2020 +0200 c++: Avoid strict_aliasing_warning on dependent types or expressions [PR94951] The following testcase gets a bogus warning during build_base_path, when cp_build_indirect_ref* calls strict_aliasing_warning with a dependent expression. IMHO calling get_alias_set etc. on dependent types feels wrong to me, we should just defer the warnings in those cases until instantiation and only handle the cases where neither type nor expr are dependent. 2020-05-06 Jakub Jelinek PR c++/94951 * typeck.c (cp_strict_aliasing_warning): New function. (cp_build_indirect_ref_1, build_reinterpret_cast_1): Use it instead of strict_aliasing_warning. * g++.dg/warn/Wstrict-aliasing-bogus-tmpl.C: New test.
[Bug c++/94951] [8/9/10/11 Regression] dereferencing type-punned pointer will break strict-aliasing rules when using super class for a template type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94951 Jakub Jelinek changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org --- Comment #5 from Jakub Jelinek --- Created attachment 48456 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48456=edit gcc11-pr94951.patch Untested fix. It seems just wrong to call the c-family strict_aliasing_warning for dependent types, we shouldn't query alias sets of dependent types and do any decisions based on what that gives.
[Bug c++/94951] [8/9/10/11 Regression] dereferencing type-punned pointer will break strict-aliasing rules when using super class for a template type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94951 Jakub Jelinek changed: What|Removed |Added Priority|P3 |P2
[Bug c++/94951] [8/9/10/11 Regression] dereferencing type-punned pointer will break strict-aliasing rules when using super class for a template type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94951 --- Comment #4 from Jakub Jelinek --- And the array isn't needed either: struct A { int a; }; template struct B : public A { static B foo () { B t; t.a = 4; return t; } };
[Bug c++/94951] [8/9/10/11 Regression] dereferencing type-punned pointer will break strict-aliasing rules when using super class for a template type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94951 --- Comment #3 from Jakub Jelinek --- Slightly simplified testcase: struct A { unsigned a[32]; }; template struct B : public A { static B foo () { B t; t.a[0] = 4; return t; } };
[Bug c++/94951] [8/9/10/11 Regression] dereferencing type-punned pointer will break strict-aliasing rules when using super class for a template type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94951 Jakub Jelinek changed: What|Removed |Added Target Milestone|--- |8.5 CC||jakub at gcc dot gnu.org, ||jason at gcc dot gnu.org Summary|dereferencing type-punned |[8/9/10/11 Regression] |pointer will break |dereferencing type-punned |strict-aliasing rules when |pointer will break |using super class for a |strict-aliasing rules when |template type |using super class for a ||template type --- Comment #2 from Jakub Jelinek --- Started with r7-755-g23cb72663051cd3f5a8952d4aa2186d50243b7d0
[Bug c++/94951] dereferencing type-punned pointer will break strict-aliasing rules when using super class for a template type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94951 Richard Biener changed: What|Removed |Added Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Keywords||diagnostic Last reconfirmed||2020-05-05 --- Comment #1 from Richard Biener --- We're warning via #0 warning_at (location=426247, opt=664, gmsgid=0x2a36f08 "dereferencing type-punned pointer will break strict-aliasing rules") at ../../src/trunk/gcc/diagnostic.c:1442 #1 0x00e324c9 in strict_aliasing_warning (loc=426247, type=, expr=) at ../../src/trunk/gcc/c-family/c-warn.c:729 #2 0x00d45def in cp_build_indirect_ref_1 (loc=426535, ptr=, errorstring=RO_NULL, complain=3, do_fold=true) at ../../src/trunk/gcc/cp/typeck.c:3364 #3 0x00d46191 in cp_build_fold_indirect_ref ( pointer=) at ../../src/trunk/gcc/cp/typeck.c:3444 #4 0x009ecb7a in build_base_path (code=PLUS_EXPR, expr=, binfo=, nonnull=1, complain=3) at ../../src/trunk/gcc/cp/class.c:513 #5 0x00d4309f in build_class_member_access_expr (object=..., member=, access_path=, preserve_reference=false, complain=3) at ../../src/trunk/gcc/cp/typeck.c:2603 #6 0x00d45377 in finish_class_member_access_expr (object=..., name=, template_p=false, complain=3) at ../../src/trunk/gcc/cp/typeck.c:3209
[Bug c++/94951] New: dereferencing type-punned pointer will break strict-aliasing rules when using super class for a template type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94951 Bug ID: 94951 Summary: dereferencing type-punned pointer will break strict-aliasing rules when using super class for a template type Product: gcc Version: 9.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jorgen.lind at gmail dot com Target Milestone: --- The following program issues the warning when compiled with -O2 or -O3. The workaround is to static_cast usage of members to super class. In the godbolt example its sufficient to add brackets around the class instance before member access, but was not sufficient in a more complex example. The behavior is present from 7.1 until trunk. Godbolt link:https://godbolt.org/z/Kfp-ac #include struct A { uint32_t someData[32]; }; template struct B : public A { static B createB(uint32_t ()[32]) { B toReturn; toReturn.someData[2] = 4; return toReturn; } };
[Bug c/94337] Incorrect "dereferencing type-punned pointer will break strict-aliasing rules" warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94337 --- Comment #2 from Vincent Lefèvre --- Why not having a level with no false positives? This would avoid to disable the warning globally. IMHO, using it when a union is involved is likely to generate false positives.
[Bug c/94337] Incorrect "dereferencing type-punned pointer will break strict-aliasing rules" warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94337 --- Comment #1 from Richard Biener --- The warning only looks at the single expression it quotes which isn't really enough to discover you are doing right. It tries to be helpful - if you know better then disable the warning.
[Bug c/94337] New: Incorrect "dereferencing type-punned pointer will break strict-aliasing rules" warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94337 Bug ID: 94337 Summary: Incorrect "dereferencing type-punned pointer will break strict-aliasing rules" warning Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: vincent-gcc at vinc17 dot net Target Milestone: --- Consider the following example. #include struct s1 { int a; }; struct s2 { int a, b; }; int main (void) { union { struct s1 m1[1]; struct s2 m2[1]; } u; (u.m2)->b = 17; printf ("%d\n", ((struct s2 *) (struct s1 *) u.m2)->b); printf ("%d\n", ((struct s2 *) u.m1)->b); return 0; } zira:~> gcc-10 tst.c -o tst -O2 -Wstrict-aliasing tst.c: In function ‘main’: tst.c:22:20: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 22 | printf ("%d\n", ((struct s2 *) u.m1)->b); | ~^~~ But there is no type-punning here. All accesses are done via struct s2. Everything else is pointer conversions, which are not related to the aliasing rules.
[Bug c++/41874] Incorrect "dereferencing type-punned pointer will break strict-aliasing rules" warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874 Jonathan Wakely changed: What|Removed |Added Status|RESOLVED|REOPENED Resolution|FIXED |--- --- Comment #16 from Jonathan Wakely --- (In reply to Richard Biener from comment #12) > No, the warning is gone from all releases that are still maintained. Looks like this wasn't true.
[Bug c++/41874] Incorrect "dereferencing type-punned pointer will break strict-aliasing rules" warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874 --- Comment #15 from Aso Renji --- (In reply to Jonathan Wakely from comment #14) > What do you mean by "same problem"? The original testcase does not produce a > warning with GCC 6.3.0 No, this warning still appear if (and only if) you use -O2 or -O3 optimization key (as it be in startpost with "g++ -O3 -Wstrict-aliasing test.cc -o /dev/null" line). If I don't use any optimization - yes, this warning don't appeared.
[Bug c++/41874] Incorrect "dereferencing type-punned pointer will break strict-aliasing rules" warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874 --- Comment #14 from Jonathan Wakely --- (In reply to Aso Renji from comment #13) > Still have same problem in g++ 6.3.0. So, please reopen this bug. What do you mean by "same problem"? The original testcase does not produce a warning with GCC 6.3.0 If you get a warning for a different piece of code then please open a new bug, this one is fixed.
[Bug c++/41874] Incorrect "dereferencing type-punned pointer will break strict-aliasing rules" warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874 Aso Renji changed: What|Removed |Added CC||asorenji at gmail dot com --- Comment #13 from Aso Renji --- Still have same problem in g++ 6.3.0. So, please reopen this bug.
[Bug c++/80593] [7 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593 Jonathan Wakely changed: What|Removed |Added CC||joerg.rich...@pdv-fs.de --- Comment #15 from Jonathan Wakely --- *** Bug 81858 has been marked as a duplicate of this bug. ***
[Bug c++/81145] bogus "dereferencing type-punned pointer will break strict-aliasing rules" diagnostic with incomplete class type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81145 --- Comment #5 from Richard Smith --- Yes, according to godbolt this occurs in GCC 4.4 - 7.1, but not in trunk. Unlike PR80593, it does not appear to be a GCC 7 regression, but it sure seems plausible that that change fixed it =)
[Bug c++/80593] [7 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593 Jonathan Wakely changed: What|Removed |Added CC||richard-gccbugzilla@metafoo ||.co.uk --- Comment #14 from Jonathan Wakely --- *** Bug 81145 has been marked as a duplicate of this bug. ***
[Bug c++/81145] bogus "dereferencing type-punned pointer will break strict-aliasing rules" diagnostic with incomplete class type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81145 Jonathan Wakely changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |DUPLICATE --- Comment #4 from Jonathan Wakely --- Indeed, the warning is gone with a current gcc-7-branch build. *** This bug has been marked as a duplicate of bug 80593 ***
[Bug c++/81145] bogus "dereferencing type-punned pointer will break strict-aliasing rules" diagnostic with incomplete class type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81145 --- Comment #3 from Jonathan Wakely --- Is the version 7.0.1 correct? Unless you're still seeing this with a fairly recent 7.1.1 build from the gcc-7-branch this is probably a dup of Bug 80593
[Bug c++/81145] bogus "dereferencing type-punned pointer will break strict-aliasing rules" diagnostic with incomplete class type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81145 --- Comment #2 from Richard Smith --- I've tried a few things and not found any way to get wrong code. I think you're right that this is just a diagnostic issue.
[Bug c++/81145] bogus "dereferencing type-punned pointer will break strict-aliasing rules" diagnostic with incomplete class type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81145 Marc Glisse changed: What|Removed |Added Keywords||diagnostic --- Comment #1 from Marc Glisse --- Can you make it generate wrong code? I expect it is only the warning that is broken.
[Bug c++/81145] New: bogus "dereferencing type-punned pointer will break strict-aliasing rules" diagnostic with incomplete class type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81145 Bug ID: 81145 Summary: bogus "dereferencing type-punned pointer will break strict-aliasing rules" diagnostic with incomplete class type Product: gcc Version: 7.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: richard-gccbugzilla at metafoo dot co.uk Target Milestone: --- Testcase: struct B { int n; }; struct A #ifndef BUG { B b; } #endif ; extern A a; int n = reinterpret_cast<B*>()->n; This produces a bogus "dereferencing type-punned pointer will break strict-aliasing rules" diagnostic with -DBUG, but correctly suppresses the warning when the definition of A is visible. Note that under C++ P0137R1 / DR1776, the A object is pointer-interconvertible with its b member, so the reinterpret_cast produces a usable pointer to a.b, regardless of whether the definition of A is visible. Perhaps GCC's TBAA should be less aggressive when comparing an incomplete type against (at least) a standard-layout type?
[Bug c++/80593] [7 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593 --- Comment #13 from Daniel Black --- Thanks Richard.
[Bug c++/80593] [7 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593 Richard Biener changed: What|Removed |Added Status|ASSIGNED|RESOLVED Known to work||7.1.1 Resolution|--- |FIXED Known to fail||7.1.0 --- Comment #12 from Richard Biener --- Fixed.
[Bug c++/80593] [7 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593 --- Comment #11 from Richard Biener --- Author: rguenth Date: Wed Jun 7 13:07:06 2017 New Revision: 248970 URL: https://gcc.gnu.org/viewcvs?rev=248970=gcc=rev Log: 2017-06-07 Richard BienerBackport from mainline 2017-05-02 Richard Biener PR tree-optimization/80549 * tree-cfgcleanup.c (mfb_keep_latches): New helper. (cleanup_tree_cfg_noloop): Create forwarders to known loop headers if they do not have a preheader. * gcc.dg/torture/pr80549.c: New testcase. 2017-05-19 Richard Biener PR c++/80593 * c-warn.c (strict_aliasing_warning): Do not warn for accesses to alias-set zero memory. * g++.dg/warn/Wstrict-aliasing-bogus-char-2.C: New testcase. * g++.dg/warn/Wstrict-aliasing-6.C: Adjust expected outcome. 2017-05-26 Richard Biener PR tree-optimization/80842 * tree-ssa-ccp.c (set_lattice_value): Always meet with the old value. * gcc.dg/torture/pr80842.c: New testcase. 2017-05-31 Richard Biener PR tree-optimization/80906 * graphite-isl-ast-to-gimple.c (copy_loop_close_phi_nodes): Get and pass through iv_map. (copy_bb_and_scalar_dependences): Adjust. (translate_pending_phi_nodes): Likewise. (copy_loop_close_phi_args): Handle code-generating IVs instead of ICEing. * gcc.dg/graphite/pr80906.c: New testcase. 2017-05-11 Richard Biener PR tree-optimization/80705 * tree-vect-data-refs.c (vect_analyze_data_refs): DECL_NONALIASED bases are not vectorizable. * gcc.dg/vect/bb-slp-pr80705.c: New testcase. Added: branches/gcc-7-branch/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-char-2.C branches/gcc-7-branch/gcc/testsuite/gcc.dg/graphite/pr80906.c branches/gcc-7-branch/gcc/testsuite/gcc.dg/torture/pr80549.c branches/gcc-7-branch/gcc/testsuite/gcc.dg/torture/pr80842.c branches/gcc-7-branch/gcc/testsuite/gcc.dg/vect/bb-slp-pr80705.c Modified: branches/gcc-7-branch/gcc/ChangeLog branches/gcc-7-branch/gcc/c-family/ChangeLog branches/gcc-7-branch/gcc/c-family/c-warn.c branches/gcc-7-branch/gcc/graphite-isl-ast-to-gimple.c branches/gcc-7-branch/gcc/testsuite/ChangeLog branches/gcc-7-branch/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-6.C branches/gcc-7-branch/gcc/tree-cfgcleanup.c branches/gcc-7-branch/gcc/tree-ssa-ccp.c branches/gcc-7-branch/gcc/tree-vect-data-refs.c
[Bug c++/80593] [7 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593 Daniel Black changed: What|Removed |Added CC||daniel.black at au dot ibm.com --- Comment #10 from Daniel Black --- FYI I have tested from the gcc master (x86_64-pc-linux-gnu-g++ (GCC) 8.0.0 20170605 (experimental)) and it doesn't identify the the following bit of rocksdb code as a warning where previously it did. So fixed for me on master. ./db/write_thread.h:227:78: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] return *static_cast<std::mutex*>(static_cast<void*>(_mutex_bytes)); ref: https://github.com/facebook/rocksdb/issues/2382 Still fails using the gcc at the head of the gcc-7-branch however
[Bug c++/80593] [7 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593 Cory Fields changed: What|Removed |Added CC||lists at coryfields dot com --- Comment #9 from Cory Fields --- I assume based on the milestone that this will be backported to 7.2? Boost's aligned_storage is affected as well, causing floods of warnings from several of its containers (multi_index, at least) which use it.
[Bug c++/80593] [7 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593 Richard Biener changed: What|Removed |Added Known to work||8.0 Summary|[7/8 Regression] GCC 7, |[7 Regression] GCC 7, |aligned_storage and |aligned_storage and |“dereferencing type-punned |“dereferencing type-punned |pointer will break |pointer will break |strict-aliasing rules” |strict-aliasing rules” --- Comment #8 from Richard Biener --- Fixed on trunk sofar.
[Bug c++/80593] [7/8 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593 --- Comment #7 from Richard Biener --- Author: rguenth Date: Fri May 19 12:34:54 2017 New Revision: 248269 URL: https://gcc.gnu.org/viewcvs?rev=248269=gcc=rev Log: 2017-05-19 Richard BienerPR c++/80593 * c-warn.c (strict_aliasing_warning): Do not warn for accesses to alias-set zero memory. * g++.dg/warn/Wstrict-aliasing-bogus-char-2.C: New testcase. * g++.dg/warn/Wstrict-aliasing-6.C: Adjust expected outcome. Added: trunk/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-char-2.C Modified: trunk/gcc/c-family/ChangeLog trunk/gcc/c-family/c-warn.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-6.C
[Bug c++/80593] [7/8 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593 Richard Biener changed: What|Removed |Added CC||s-beyer at gmx dot net --- Comment #6 from Richard Biener --- *** Bug 80827 has been marked as a duplicate of this bug. ***
[Bug c++/80593] [7/8 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593 --- Comment #5 from Richard Biener --- Breaks at least g++.dg/warn/Wstrict-aliasing-6.C which I think is expected fallout.
[Bug c++/80593] [7/8 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593 Richard Biener changed: What|Removed |Added Priority|P3 |P2 Status|NEW |ASSIGNED CC||rguenth at gcc dot gnu.org Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org --- Comment #4 from Richard Biener --- (In reply to Jakub Jelinek from comment #3) > The set1 == 0 stuff has been added in r136679. Yep, to not regress some -Wstrict-aliasing testcase I think. I'll test Index: gcc/c-family/c-warn.c === --- gcc/c-family/c-warn.c (revision 248179) +++ gcc/c-family/c-warn.c (working copy) @@ -537,10 +537,10 @@ strict_aliasing_warning (tree otype, tre = get_alias_set (TREE_TYPE (TREE_OPERAND (expr, 0))); alias_set_type set2 = get_alias_set (TREE_TYPE (type)); - if (set1 != set2 && set2 != 0 - && (set1 == 0 - || (!alias_set_subset_of (set2, set1) - && !alias_sets_conflict_p (set1, set2 + if (set2 != 0 + && set1 != set2 + && !alias_set_subset_of (set2, set1) + && !alias_sets_conflict_p (set1, set2)) { warning (OPT_Wstrict_aliasing, "dereferencing type-punned " "pointer will break strict-aliasing rules");
[Bug c++/80593] [7/8 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593 --- Comment #3 from Jakub Jelinek --- The set1 == 0 stuff has been added in r136679.
[Bug c++/80593] [7/8 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek --- Indeed, started with r246866.
[Bug c++/80593] [7/8 Regression] GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593 Richard Biener changed: What|Removed |Added Keywords||diagnostic Status|UNCONFIRMED |NEW Last reconfirmed||2017-05-02 Target Milestone|--- |7.2 Summary|GCC 7, aligned_storage and |[7/8 Regression] GCC 7, |“dereferencing type-punned |aligned_storage and |pointer will break |“dereferencing type-punned |strict-aliasing rules” |pointer will break ||strict-aliasing rules” Ever confirmed|0 |1 --- Comment #1 from Richard Biener --- Confirmed. This likely regressed with the introduction of TYPE_TYPELESS_STORAGE which aligned_storage now is, and thus 'storage' gets alias-set zero itself running into /* warn_strict_aliasing >= 3. This includes the default (3). Only warn if the cast is dereferenced immediately. */ alias_set_type set1 = get_alias_set (TREE_TYPE (TREE_OPERAND (expr, 0))); alias_set_type set2 = get_alias_set (TREE_TYPE (type)); if (set1 != set2 && set2 != 0 && (set1 == 0 || (!alias_set_subset_of (set2, set1) && !alias_sets_conflict_p (set1, set2 { warning (OPT_Wstrict_aliasing, "dereferencing type-punned " "pointer will break strict-aliasing rules"); return true; with set1 == 0.
[Bug c++/80593] New: GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules”
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80593 Bug ID: 80593 Summary: GCC 7, aligned_storage and “dereferencing type-punned pointer will break strict-aliasing rules” Product: gcc Version: 7.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: freddie_chopin at op dot pl Target Milestone: --- I've posted this info to the gcc mailing list. Richard Biener suggested opening a bug report, so here it is. https://gcc.gnu.org/ml/gcc/2017-05/msg00013.html Following example code is warning-free on GCC 4.9, GCC 5 and GCC 6. It is also warning free on some older GCC 7 snapshots (like 7-20170409). -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- $ cat punning.cpp template struct aligned_storage { union type { unsigned char __data[_Len]; struct __attribute__((__aligned__((_Align { } __align; }; }; aligned_storage<sizeof(int), alignof(int)>::type storage; int main() { *reinterpret_cast<int*>() = 42; } $ g++ -Wall -O2 -c punning.cpp $ -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- However in the most recent GCC 7 snapshots (including both RCs), it gives a warning about type punning: -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- $ g++ -Wall -O2 -c punning.cpp punning.cpp: In function 'int main()': punning.cpp:15:35: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] *reinterpret_cast<int*>() = 42; ^ $ -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 --
dereferencing type-punned pointer will break strict-aliasing rules
Hi, i wan't to create aliase (name and type) for the elements of an char-array. Unfortunately my gcc produce the warning "dereferencing type-punned pointer will break strict-aliasing rules", if i use -O2 or bigger. Since i set -Werror, the warning will become an error. I attached an example to this mail. To compile and generate the problem, i use "gcc -O2 -Werror -Wall main.cpp". I found an workaround (without using pragma, or somethink else), with it's included in the code, too. To activate, pass an extra "-DWorking" to the gcc-Command. The workaround is working, but using an pointer is ugly. Best regrads, Marcel -- Dipl. Ing (FH) Marcel Behlau (Software Developer) ELFIN GmbH Siegburger Straße 215 50679 Köln Germany Tel: +49 (221) 6778932-0 Fax: +49 (221) 6778932-2 marcel.beh...@elfin.de www.elfin.de //gcc -O2 -Wall main.cpp //gcc -O2 -Wall main.cpp -DWorking //#define Working struct Ec { char ecData; }; class ClassZero { public: char data[8]; char* pointer; Ec& ec0; #ifdef Working ClassZero() : pointer(data), ec0(*(Ec*)(pointer)) { } #else ClassZero() : ec0(*(Ec*)(data)) { } #endif }; int main() { return 0; }
[Bug c++/41874] Incorrect dereferencing type-punned pointer will break strict-aliasing rules warning
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874 Paolo Carlini paolo.carlini at oracle dot com changed: What|Removed |Added CC|gcc-bugs at gcc dot gnu.org | --- Comment #11 from Paolo Carlini paolo.carlini at oracle dot com 2012-10-15 09:27:13 UTC --- Richard, is this still an issue?
[Bug c++/41874] Incorrect dereferencing type-punned pointer will break strict-aliasing rules warning
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874 Richard Biener rguenth at gcc dot gnu.org changed: What|Removed |Added Status|NEW |RESOLVED Resolution||FIXED Target Milestone|--- |4.5.0 --- Comment #12 from Richard Biener rguenth at gcc dot gnu.org 2012-10-15 09:45:11 UTC --- No, the warning is gone from all releases that are still maintained.
[Bug c++/41874] Incorrect dereferencing type-punned pointer will break strict-aliasing rules warning
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874 --- Comment #9 from Ilya Murav'jov muravev at yandex dot ru 2010-10-06 19:43:30 UTC --- I've come across another weird warning emission in g++ 4.4: $ cat test.cc #include new struct interface_type { virtual interface_type* clone(void* storage) const { return ::new (storage) interface_type(); } }; struct poly_base { poly_base(const interface_type x) { x.clone(data); } typedef char storage_t[100]; storage_t data; }; struct instance_t: interface_type {}; int main() { instance_t pi; poly_base p1(pi); interface_type* ptr = (interface_type*)(p1.data); poly_base p2(*ptr); } $ g++ -O3 -Wstrict-aliasing test.cc -o /dev/null test.cc: In function ‘int main()’: test.cc:12: warning: dereferencing pointer ‘ptr’ does break strict-aliasing rules test.cc:25: note: initialized from here $ g++ -v Using built-in specs. Target: i486-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.1-4ubuntu9' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu Thread model: posix gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9) I get this only in g++ 4.4, g++ 4.5 does not warn. I want to note that this is a different type of warning about strict-aliasing rules, likely a more serious one. Can anyone tell what a difference between warning: dereferencing type-punned pointer will break strict-aliasing rules and warning: dereferencing pointer ‘ptr’ does break strict-aliasing rules?
[Bug c++/41874] Incorrect dereferencing type-punned pointer will break strict-aliasing rules warning
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874 --- Comment #10 from rguenther at suse dot de rguenther at suse dot de 2010-10-06 20:56:56 UTC --- On Wed, 6 Oct 2010, muravev at yandex dot ru wrote: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874 --- Comment #9 from Ilya Murav'jov muravev at yandex dot ru 2010-10-06 19:43:30 UTC --- I've come across another weird warning emission in g++ 4.4: $ cat test.cc #include new struct interface_type { virtual interface_type* clone(void* storage) const { return ::new (storage) interface_type(); } }; struct poly_base { poly_base(const interface_type x) { x.clone(data); } typedef char storage_t[100]; storage_t data; }; struct instance_t: interface_type {}; int main() { instance_t pi; poly_base p1(pi); interface_type* ptr = (interface_type*)(p1.data); poly_base p2(*ptr); } $ g++ -O3 -Wstrict-aliasing test.cc -o /dev/null test.cc: In function ‘int main()’: test.cc:12: warning: dereferencing pointer ‘ptr’ does break strict-aliasing rules test.cc:25: note: initialized from here $ g++ -v Using built-in specs. Target: i486-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.1-4ubuntu9' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu Thread model: posix gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9) I get this only in g++ 4.4, g++ 4.5 does not warn. I want to note that this is a different type of warning about strict-aliasing rules, likely a more serious one. Can anyone tell what a difference between warning: dereferencing type-punned pointer will break strict-aliasing rules and warning: dereferencing pointer ‘ptr’ does break strict-aliasing rules? The latter means that when doing pointer analysis GCC pruned all pointed-to objects using TBAA so the pointer ended up pointing to nothing (but still was dereferenced). The good news for you is that GCC will assume the pointer points to anything in that case, not nothing. In GCC 4.5 points-to analysis doesn't use TBAA to prune the sets anymore (because its fundamentally wrong), so the code emitting the warning was removed. Richard.
[Bug c++/41874] Incorrect dereferencing type-punned pointer will break strict-aliasing rules warning
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874 --- Comment #7 from Ilya Murav'jov muravev at yandex dot ru 2010-10-05 00:10:20 UTC --- AFAIK, users of Boost.Function suffer from this PR too. https://svn.boost.org/trac/boost/ticket/4538
[Bug c++/41874] Incorrect dereferencing type-punned pointer will break strict-aliasing rules warning
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874 Florian Weimer fw at gcc dot gnu.org changed: What|Removed |Added CC||fw at gcc dot gnu.org --- Comment #8 from Florian Weimer fw at gcc dot gnu.org 2010-10-05 04:48:54 UTC --- (In reply to comment #6) The general problem is that alias analysis is hard, thus follows that proper warnings are equally hard. Note that it says will break strict-aliasing rules, not might break strict-aliasing rules (which also exists). I think the user can reasonably expect that the will break variant is actually true.
[Bug c++/41874] Incorrect dereferencing type-punned pointer will break strict-aliasing rules warning
--- Comment #5 from fw at deneb dot enyo dot de 2010-01-31 09:38 --- Isn't this a wrong-code bug? Or is the information used for the diagnostic not used by the optimizers? -- fw at deneb dot enyo dot de changed: What|Removed |Added CC||fw at deneb dot enyo dot de http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874
[Bug c++/41874] Incorrect dereferencing type-punned pointer will break strict-aliasing rules warning
--- Comment #6 from rguenth at gcc dot gnu dot org 2010-01-31 11:17 --- (In reply to comment #5) Isn't this a wrong-code bug? Or is the information used for the diagnostic not used by the optimizers? The diagnostics are independent on the optimizers, the one diagnostic that isn't (that is emitted from the optimizer itself) causes the optimizer to not optimize (well, because it saw the problem and thus there is no point in breaking things just because we can). The general problem is that alias analysis is hard, thus follows that proper warnings are equally hard. All warnings we emit are either possible false positives or if they are not the optimizers will not miscompile your code because they know there is an alias even though type-based analysis says there is not (well, this is exactly the case you want to warn about, but as analysis is hard once you can tell you can as well not exploit the mis-optimization opportunity). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874
[Bug c++/41874] Incorrect dereferencing type-punned pointer will break strict-aliasing rules warning
--- Comment #1 from pinskia at gcc dot gnu dot org 2009-11-06 09:09 --- 4.5 also fails and I cannot figure why if I do: #include new struct APInt { int i; }; int main() { APInt I; void *d; char Data[sizeof(APInt)]; new((void*)Data)APInt(); d = Data; *(APInt*)d = I; } GCC does not warn. -- pinskia at gcc dot gnu dot org changed: What|Removed |Added CC||rguenth at gcc dot gnu dot ||org Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Known to fail||4.5.0 Last reconfirmed|-00-00 00:00:00 |2009-11-06 09:09:42 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874
[Bug c++/41874] Incorrect dereferencing type-punned pointer will break strict-aliasing rules warning
--- Comment #2 from rguenther at suse dot de 2009-11-06 09:16 --- Subject: Re: Incorrect dereferencing type-punned pointer will break strict-aliasing rules warning On Fri, 6 Nov 2009, pinskia at gcc dot gnu dot org wrote: --- Comment #1 from pinskia at gcc dot gnu dot org 2009-11-06 09:09 --- 4.5 also fails and I cannot figure why if I do: fails? #include new struct APInt { int i; }; int main() { APInt I; void *d; char Data[sizeof(APInt)]; new((void*)Data)APInt(); d = Data; *(APInt*)d = I; } GCC does not warn. Of course not - the code is perfectly valid (apart from Data not having suitable alignment for APInt, but that's unrelated to aliasing issues). Richard. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874
[Bug c++/41874] Incorrect dereferencing type-punned pointer will break strict-aliasing rules warning
--- Comment #3 from pinskia at gcc dot gnu dot org 2009-11-06 09:18 --- --- Comment #1 from pinskia at gcc dot gnu dot org 2009-11-06 09:09 --- 4.5 also fails Fails in that it warns still. The first example warns with 4.5, while adding an extra variable and doing a cast to void* causes GCC not to warn. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874
[Bug c++/41874] Incorrect dereferencing type-punned pointer will break strict-aliasing rules warning
--- Comment #4 from rguenth at gcc dot gnu dot org 2009-11-06 09:20 --- Btw, this warning is emitted from the frontend which only warns if it sees the address of an object casted, not random pointers (because of the many false positives). The frontend code also has no idea of the concept of a dynamic type. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874
[Bug c/41673] [4.5 Regression] variable-length array dereference inside sizeof gives warning: dereferencing type-punned pointer will break strict-aliasing rules
--- Comment #4 from hjl at gcc dot gnu dot org 2009-10-30 16:05 --- Subject: Bug 41673 Author: hjl Date: Fri Oct 30 16:04:41 2009 New Revision: 153759 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=153759 Log: 2009-10-30 H.J. Lu hongjiu...@intel.com Backport from mainline: 2009-10-30 Dodji Seketeli do...@redhat.com PR c++/41863 * g++.dg/template/sizeof12.C: New test. 2009-10-29 Martin Jambor mjam...@suse.cz PR tree-optimization/41775 * g++.dg/torture/pr41775.C: New testcase. 2009-10-28 Jakub Jelinek ja...@redhat.com PR debug/41801 * g++.dg/ext/sync-3.C: New test. 2009-10-27 Jakub Jelinek ja...@redhat.com PR c++/41020 * g++.dg/lookup/extern-c-redecl5.C: Fix up regexp. 2009-10-26 Jakub Jelinek ja...@redhat.com PR bootstrap/41345 * gcc.dg/pr41345.c: New test. 2009-10-26 Dodji Seketeli do...@redhat.com PR c++/41785 * g++.dg/cpp0x/variadic96.C: New test. 2009-10-26 Dodji Seketeli do...@redhat.com PR c++/41020 * g++.dg/lookup/extern-c-redecl2.C: New test. * g++.dg/lookup/extern-c-redecl3.C: Likewise. * g++.dg/lookup/extern-c-redecl4.C: Likewise. * g++.dg/lookup/extern-c-redecl5.C: Likewise. 2009-10-23 Joseph Myers jos...@codesourcery.com PR c/40033 * gcc.dg/noncompile/pr40033-1.c: New test. 2009-10-23 Joseph Myers jos...@codesourcery.com PR c/41673 * gcc.dg/Wstrict-aliasing-bogus-vla-1.c: New test. 2009-10-21 Sebastian Pop sebastian@amd.com PR tree-optimization/41497 * gcc.dg/tree-ssa/pr41497.c: New. Added: branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/variadic96.C - copied unchanged from r153757, trunk/gcc/testsuite/g++.dg/cpp0x/variadic96.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/ext/sync-3.C - copied unchanged from r153757, trunk/gcc/testsuite/g++.dg/ext/sync-3.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/lookup/extern-c-redecl2.C - copied unchanged from r153757, trunk/gcc/testsuite/g++.dg/lookup/extern-c-redecl2.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C - copied unchanged from r153757, trunk/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C - copied unchanged from r153757, trunk/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/lookup/extern-c-redecl5.C - copied unchanged from r153757, trunk/gcc/testsuite/g++.dg/lookup/extern-c-redecl5.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/sizeof12.C - copied unchanged from r153757, trunk/gcc/testsuite/g++.dg/template/sizeof12.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/torture/pr41775.C - copied unchanged from r153757, trunk/gcc/testsuite/g++.dg/torture/pr41775.C branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/Wstrict-aliasing-bogus-vla-1.c - copied unchanged from r153758, trunk/gcc/testsuite/gcc.dg/Wstrict-aliasing-bogus-vla-1.c branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/noncompile/pr40033-1.c - copied unchanged from r153758, trunk/gcc/testsuite/gcc.dg/noncompile/pr40033-1.c branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr41345.c - copied unchanged from r153757, trunk/gcc/testsuite/gcc.dg/pr41345.c branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/tree-ssa/pr41497.c - copied unchanged from r153758, trunk/gcc/testsuite/gcc.dg/tree-ssa/pr41497.c Modified: branches/gcc-4_4-branch/gcc/testsuite/ChangeLog -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41673
[Bug c++/41874] New: Incorrect dereferencing type-punned pointer will break strict-aliasing rules warning
$ cat test.cc #include new struct APInt { int i; }; int main() { APInt I; char Data[sizeof(APInt)]; new((void*)Data)APInt(); *(APInt*)Data = I; } $ g++ -O3 -Wstrict-aliasing test.cc -o /dev/null test.cc: In function 'int main()': test.cc:9: warning: dereferencing type-punned pointer will break strict-aliasing rules test.cc:9: warning: dereferencing type-punned pointer will break strict-aliasing rules $ g++ -v Using built-in specs. Target: i386-apple-darwin9 Configured with: ../gcc-4.4.1/configure --prefix=/opt/local --build=i386-apple-darwin9 --enable-languages=c,c++,objc,obj-c++,java,fortran --libdir=/opt/local/lib/gcc44 --includedir=/opt/local/include/gcc44 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.4 --with-gxx-include-dir=/opt/local/include/gcc44/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local Thread model: posix gcc version 4.4.1 (GCC) The warning goes away if I change *(APInt*)Data = I; to *(APInt*)(void*)Data = I; even though an extra cast through void* can't improve the situation wrt strict-aliasing. -- Summary: Incorrect dereferencing type-punned pointer will break strict-aliasing rules warning Product: gcc Version: 4.4.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jyasskin at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874
[Bug c/41673] [4.5 Regression] variable-length array dereference inside sizeof gives warning: dereferencing type-punned pointer will break strict-aliasing rules
--- Comment #2 from jsm28 at gcc dot gnu dot org 2009-10-23 12:18 --- Subject: Bug 41673 Author: jsm28 Date: Fri Oct 23 12:18:42 2009 New Revision: 153496 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=153496 Log: PR c/41673 * alias.c (get_alias_set): Call langhook before returning 0 for types with structural equality. * c-common.c (c_common_get_alias_set): Use alias set of element type for arrays with structural comparison. testsuite: * gcc.dg/Wstrict-aliasing-bogus-vla-1.c: New test. Added: trunk/gcc/testsuite/gcc.dg/Wstrict-aliasing-bogus-vla-1.c Modified: trunk/gcc/ChangeLog trunk/gcc/alias.c trunk/gcc/c-common.c trunk/gcc/testsuite/ChangeLog -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41673
[Bug c/41673] [4.5 Regression] variable-length array dereference inside sizeof gives warning: dereferencing type-punned pointer will break strict-aliasing rules
--- Comment #3 from jsm28 at gcc dot gnu dot org 2009-10-23 12:23 --- Fixed for 4.5. -- jsm28 at gcc dot gnu dot org changed: What|Removed |Added Status|ASSIGNED|RESOLVED Known to work||4.5.0 Resolution||FIXED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41673
[Bug c/41673] [4.5 Regression] variable-length array dereference inside sizeof gives warning: dereferencing type-punned pointer will break strict-aliasing rules
--- Comment #1 from jsm28 at gcc dot gnu dot org 2009-10-23 01:03 --- Testing a patch. -- jsm28 at gcc dot gnu dot org changed: What|Removed |Added AssignedTo|unassigned at gcc dot gnu |jsm28 at gcc dot gnu dot org |dot org | Status|UNCONFIRMED |ASSIGNED Ever Confirmed|0 |1 Last reconfirmed|-00-00 00:00:00 |2009-10-23 01:03:03 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41673
[Bug c/41673] New: 4.5.0 20091008 variable-length array dereference inside sizeof gives warning: dereferencing type-punned pointer will break strict-aliasing rules
A variable-length array pointer 'dereference' inside sizeof() is causing GCC to give an aliasing warning. I can think of no reason why completely compiletime-static sizeof() activity could create an aliasing violation. I've included a contrived example showing 4.5.0 producing the warning while 4.4.1 does not complain: [gmaxw...@floodlamp tmp]$ cat test.c #include string.h int main(int argc, char *argv[]) { float x[argc]; float y[argc]; return NULL == memcpy(y, x, argc * sizeof(*x)); } [gmaxw...@floodlamp tmp]$ /usr/local/bin/gcc -std=gnu99 -O2 -Wall -o test test.c test.c: In function main: test.c:6:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [gmaxw...@floodlamp tmp]$ /usr/local/bin/gcc -v Using built-in specs. COLLECT_GCC=/usr/local/bin/gcc COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.5.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ./configure --with-ppl --with-cloog --with-gmp --enable-lto Thread model: posix gcc version 4.5.0 20091008 (experimental) (GCC) [gmaxw...@floodlamp tmp]$ /usr/bin/gcc -std=gnu99 -O2 -Wall -o test test.c [gmaxw...@floodlamp tmp]$ /usr/bin/gcc -v Using built-in specs. Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i586 --build=x86_64-redhat-linux Thread model: posix gcc version 4.4.1 20090725 (Red Hat 4.4.1-2) (GCC) The -O2 plus sizeof(*x) anywhere where x is a var-array is necessary and sufficient to trigger this. Switching to a statically sized array avoids the warning. The actual use-case where I hit this is where sizeof() is used in this manner when a type is selected by some compile time configuration and manually restating the type in sizeof() would require a great many more ifdefs. -- Summary: 4.5.0 20091008 variable-length array dereference inside sizeof gives warning: dereferencing type-punned pointer will break strict-aliasing rules Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gmaxwell at gmail dot com GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41673
[Bug c/41673] [4.5 Regression] variable-length array dereference inside sizeof gives warning: dereferencing type-punned pointer will break strict-aliasing rules
-- rguenth at gcc dot gnu dot org changed: What|Removed |Added Keywords||diagnostic Summary|4.5.0 20091008 variable-|[4.5 Regression] variable- |length array dereference|length array dereference |inside sizeof gives |inside sizeof gives |warning: dereferencing |warning: dereferencing |type-punned pointer will|type-punned pointer will |break strict-aliasing rules|break strict-aliasing rules Target Milestone|--- |4.5.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41673
[Bug c++/32260] [4.3 Regression] too many warning: dereferencing type-punned pointer will break strict-aliasing rules
--- Comment #7 from pcarlini at suse dot de 2007-11-11 14:04 --- *** Bug 34066 has been marked as a duplicate of this bug. *** -- pcarlini at suse dot de changed: What|Removed |Added CC||guillaume dot melquiond at ||ens-lyon dot fr http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32260
[Bug c++/32260] [4.3 Regression] too many warning: dereferencing type-punned pointer will break strict-aliasing rules
--- Comment #4 from jakub at gcc dot gnu dot org 2007-11-01 11:57 --- Testing a fix. -- jakub at gcc dot gnu dot org changed: What|Removed |Added AssignedTo|unassigned at gcc dot gnu |jakub at gcc dot gnu dot org |dot org | Status|NEW |ASSIGNED Last reconfirmed|2007-06-11 21:19:44 |2007-11-01 11:57:35 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32260
[Bug c++/32260] [4.3 Regression] too many warning: dereferencing type-punned pointer will break strict-aliasing rules
--- Comment #5 from jakub at gcc dot gnu dot org 2007-11-01 22:50 --- Subject: Bug 32260 Author: jakub Date: Thu Nov 1 22:50:32 2007 New Revision: 129835 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=129835 Log: PR c++/32260 * rtti.c (enum_tinfo_kind): Fix TK_TYPE_INFO_TYPE comment. (typeid_ok_p): Use the same alias set for abi::__type_info_pseudo as for std::type_info. * g++.dg/rtti/typeid7.C: New test. Added: trunk/gcc/testsuite/g++.dg/rtti/typeid7.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/rtti.c trunk/gcc/testsuite/ChangeLog -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32260
[Bug c++/32260] [4.3 Regression] too many warning: dereferencing type-punned pointer will break strict-aliasing rules
--- Comment #6 from jakub at gcc dot gnu dot org 2007-11-01 23:09 --- Fixed. -- jakub at gcc dot gnu dot org changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution||FIXED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32260
[Bug c++/32260] [4.3 Regression] too many warning: dereferencing type-punned pointer will break strict-aliasing rules
--- Comment #3 from pcarlini at suse dot de 2007-10-26 09:00 --- *** Bug 33902 has been marked as a duplicate of this bug. *** -- pcarlini at suse dot de changed: What|Removed |Added CC||benoit dot hudson at gmail ||dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32260
[Bug c++/32260] [4.3 Regression] too many warning: dereferencing type-punned pointer will break strict-aliasing rules
--- Comment #2 from pcarlini at suse dot de 2007-09-28 17:04 --- Short term at least, could be considered a duplicate of PR32256 (and PR32368). -- pcarlini at suse dot de changed: What|Removed |Added CC||pcarlini at suse dot de http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32260
[Bug c++/32260] [4.3 Regression] too many warning: dereferencing type-punned pointer will break strict-aliasing rules
-- mmitchel at gcc dot gnu dot org changed: What|Removed |Added Priority|P3 |P2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32260
[Bug c++/32260] [4.3 Regression] too many warning: dereferencing type-punned pointer will break strict-aliasing rules
--- Comment #1 from pinskia at gcc dot gnu dot org 2007-06-11 21:19 --- Confirmed, I have not looked into this close enough but this is a front-end bug as the type (and aliasing set) of the typeid variable is different from std::type_info's. -- pinskia at gcc dot gnu dot org changed: What|Removed |Added Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Keywords||alias, diagnostic Last reconfirmed|-00-00 00:00:00 |2007-06-11 21:19:44 date|| Summary|too many warning: |[4.3 Regression] too many |dereferencing type-punned |warning: dereferencing type- |pointer will break strict- |punned pointer will break |aliasing rules |strict-aliasing rules Target Milestone|--- |4.3.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32260
[Bug c++/32260] New: too many warning: dereferencing type-punned pointer will break strict-aliasing rules
The following code, compiled with -O2 -Wall (g++ 4.3 as of 20070607), produces the following unexpected/annoying warning: test_typeinfo.cpp: In function 'int main()': test_typeinfo.cpp:5: warning: dereferencing type-punned pointer will break strict-aliasing rules test_typeinfo.cpp:5: warning: unused variable 't' ~ cat test_typeinfo.cpp #include typeinfo int main() { const std::type_info t = typeid(int); } Is this really meant to warn for such a code??? -- Summary: too many warning: dereferencing type-punned pointer will break strict-aliasing rules Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: sylvain dot pion at sophia dot inria dot fr GCC host triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32260