[Bug middle-end/61294] [4.9 Regression] erroneous memset used with constant zero length parameter warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61294 Andrew Pinski changed: What|Removed |Added CC||martin at v dot loewis.de --- Comment #16 from Andrew Pinski --- *** Bug 16794 has been marked as a duplicate of this bug. ***
[Bug middle-end/61294] [4.9 Regression] erroneous memset used with constant zero length parameter warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61294 Richard Biener changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED Target Milestone|4.9.4 |5.0 --- Comment #15 from Richard Biener --- Fixed in GCC 5+
[Bug middle-end/61294] [4.9 Regression] erroneous memset used with constant zero length parameter warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61294 Jakub Jelinek jakub at gcc dot gnu.org changed: What|Removed |Added Target Milestone|4.9.3 |4.9.4
[Bug middle-end/61294] [4.9 Regression] erroneous memset used with constant zero length parameter warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61294 --- Comment #14 from Jakub Jelinek jakub at gcc dot gnu.org --- GCC 4.9.3 has been released.
[Bug middle-end/61294] [4.9 Regression] erroneous memset used with constant zero length parameter warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61294 --- Comment #13 from Siddhesh Poyarekar siddhesh at redhat dot com --- Fixed in glibc: commit 1721f0a406e52f976f9daf6f59acf42c1dbd33ff Author: Siddhesh Poyarekar siddh...@redhat.com Date: Thu Nov 27 11:15:45 2014 +0530 Don't use __warn_memset_zero_len for gcc-5.0 or newer gcc now warns when the arguments to memset may have been accidentally transposed (i.e. length set to zero instead of the byte), so we don't need that bit of the code in glibc headers anymore. Tested on x86_64. Coe generated by gcc 4.8 is identical with or without the patch. I also tested gcc master, which does not result in any new failures. It does fail quite a few FORTIFY_SOURCE tests, but those failures are not due to this patch.
[Bug middle-end/61294] [4.9 Regression] erroneous memset used with constant zero length parameter warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61294 Richard Biener rguenth at gcc dot gnu.org changed: What|Removed |Added Keywords||diagnostic Priority|P3 |P2 Known to work||5.0 --- Comment #10 from Richard Biener rguenth at gcc dot gnu.org --- doesn't exactly work with GCC 5 now but requires an updated GLIBC AFAICS.
[Bug middle-end/61294] [4.9 Regression] erroneous memset used with constant zero length parameter warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61294 Jakub Jelinek jakub at gcc dot gnu.org changed: What|Removed |Added CC||carlos at redhat dot com --- Comment #11 from Jakub Jelinek jakub at gcc dot gnu.org --- Carlos/Siddhesh, can you please adjust the glibc headers, so that for __GNUC_PREREQ (5, 0) it doesn't contain the __warn_memset_zero_len stuff, as GCC will handle warning about it?
[Bug middle-end/61294] [4.9 Regression] erroneous memset used with constant zero length parameter warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61294 carlos at gcc dot gnu.org changed: What|Removed |Added CC||carlos at gcc dot gnu.org --- Comment #12 from carlos at gcc dot gnu.org --- (In reply to Jakub Jelinek from comment #11) Carlos/Siddhesh, can you please adjust the glibc headers, so that for __GNUC_PREREQ (5, 0) it doesn't contain the __warn_memset_zero_len stuff, as GCC will handle warning about it? Siddhesh will have a look at fixing this in master.
[Bug middle-end/61294] [4.9 Regression] erroneous memset used with constant zero length parameter warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61294 Jakub Jelinek jakub at gcc dot gnu.org changed: What|Removed |Added Target Milestone|4.9.2 |4.9.3 --- Comment #9 from Jakub Jelinek jakub at gcc dot gnu.org --- GCC 4.9.2 has been released.
[Bug middle-end/61294] [4.9 Regression] erroneous memset used with constant zero length parameter warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61294 Andrew Pinski pinskia at gcc dot gnu.org changed: What|Removed |Added CC||amodra at gmail dot com --- Comment #8 from Andrew Pinski pinskia at gcc dot gnu.org --- *** Bug 62033 has been marked as a duplicate of this bug. ***
[Bug middle-end/61294] [4.9 Regression] erroneous memset used with constant zero length parameter warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61294 Jakub Jelinek jakub at gcc dot gnu.org changed: What|Removed |Added Target Milestone|4.9.1 |4.9.2 --- Comment #7 from Jakub Jelinek jakub at gcc dot gnu.org --- GCC 4.9.1 has been released.
[Bug middle-end/61294] [4.9 Regression] erroneous memset used with constant zero length parameter warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61294 --- Comment #6 from Jakub Jelinek jakub at gcc dot gnu.org --- Author: jakub Date: Mon Jul 14 07:36:39 2014 New Revision: 212510 URL: https://gcc.gnu.org/viewcvs?rev=212510root=gccview=rev Log: PR middle-end/61294 gcc/c-family/ * c.opt (Wmemset-transposed-args): New warning. gcc/c/ * c-parser.c (c_parser_expr_list): Add new argument literal_zero_mask. If non-NULL, call c_parser_check_literal_zero. (c_parser_check_literal_zero): New function. (c_parser_postfix_expression_after_primary): Adjust c_parser_expr_list caller, handle -Wmemset-transposed-args. gcc/cp/ * cp-tree.h (LITERAL_ZERO_P): Define. * parser.c (cp_parser_parenthesized_expression_list): Add want_literal_zero_p argument, if true, for literal zeros insert INTEGER_CSTs with LITERAL_ZERO_P flag set. (cp_parser_postfix_expression): Adjust cp_parser_parenthesized_expression_list caller, handle -Wmemset-transposed-args. (literal_zeros): New variable. gcc/ * doc/invoke.texi (-Wmemset-transposed-args): Document. gcc/testsuite/ * c-c++-common/Wmemset-transposed-args1.c: New test. * c-c++-common/Wmemset-transposed-args2.c: New test. * g++.dg/warn/Wmemset-transposed-args-1.C: New test. Added: trunk/gcc/testsuite/c-c++-common/Wmemset-transposed-args1.c trunk/gcc/testsuite/c-c++-common/Wmemset-transposed-args2.c trunk/gcc/testsuite/g++.dg/warn/Wmemset-transposed-args-1.C Modified: trunk/gcc/ChangeLog trunk/gcc/c-family/ChangeLog trunk/gcc/c-family/c.opt trunk/gcc/c/ChangeLog trunk/gcc/c/c-parser.c trunk/gcc/cp/ChangeLog trunk/gcc/cp/cp-tree.h trunk/gcc/cp/parser.c trunk/gcc/doc/invoke.texi trunk/gcc/testsuite/ChangeLog
[Bug middle-end/61294] [4.9 Regression] erroneous memset used with constant zero length parameter warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61294 Jakub Jelinek jakub at gcc dot gnu.org changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #5 from Jakub Jelinek jakub at gcc dot gnu.org --- I wonder if we just shouldn't move this warning to GCC and in glibc remove it if sufficiently new GCC version is used. GCC could then warn about this in the FEs, only in the cases where user likely made a mistake (i.e. when third argument is literal 0 (rather than e.g. an expression folded to 0) and second argument is not literal 0.
[Bug middle-end/61294] [4.9 Regression] erroneous memset used with constant zero length parameter warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61294 Jason Merrill jason at gcc dot gnu.org changed: What|Removed |Added Status|WAITING |NEW CC||jason at gcc dot gnu.org Component|c++ |middle-end --- Comment #4 from Jason Merrill jason at gcc dot gnu.org --- It's clearly a false positive; the warning is intended to catch calls where the user wrote a 0 directly in the argument list for memset (which suggests accidentally transposed arguments), not cases where some execution path might result in a 0 argument (which works fine). The only question is what there is to fix either in GCC or GLIBC to avoid this false positive. A simple way to work around this is to guard the memset with if (npoints 0). The false positive seems to come up fairly often: https://sourceware.org/ml/binutils/2012-02/msg00073.html https://bugzilla.redhat.com/show_bug.cgi?id=452219 https://www.nsnam.org/bugzilla/show_bug.cgi?id=1165 Changing component to middle-end. Reduced C testcase: typedef __SIZE_TYPE__ size_t; extern void *malloc (size_t __size) __attribute__ ((__malloc__)) __attribute__ ((__warn_unused_result__)); extern void *memset (void *__s, int __c, size_t __n) __attribute__ ((__nonnull__ (1))); extern void __warn_memset_zero_len (void) __attribute__((__warning__ (memset used with constant zero length parameter; this could be due to transposed parameters))); extern __inline __attribute__((__always_inline__)) __attribute__((__artificial__)) void * memset (void *__dest, int __ch, size_t __len) { if (__builtin_constant_p (__len) __len == 0 (!__builtin_constant_p (__ch) || __ch != 0)) { __warn_memset_zero_len (); return __dest; } return __builtin___memset_chk (__dest, __ch, __len, __builtin_object_size (__dest, 0)); } int i; inline int f() { if (i) return i; else return 0; } void g(unsigned char val) { int len = f(); void *p = malloc (len); memset (p, val, len); }