Bug 62033 - okteta 4.13.97 error at -O3 -D_FORTIFY_SOURCE=2
Summary: okteta 4.13.97 error at -O3 -D_FORTIFY_SOURCE=2
Status: RESOLVED DUPLICATE of bug 61294
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-06 09:03 UTC by Alan Modra
Modified: 2014-08-06 15:30 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
delta+hand reduced testcase (627 bytes, text/x-csrc)
2014-08-06 09:03 UTC, Alan Modra
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Modra 2014-08-06 09:03:11 UTC
Created attachment 33257 [details]
delta+hand reduced testcase

Found on powerpc64le with 4.9, and then with x86_64 4.10.0 20140727

Due to __warn_memset_zero_len reference in object, we get
.../bytearraymodel_p.o: In function `memset':
.../bits/string3.h:81: warning: memset used with constant zero length parameter; this could be due to transposed parameters
collect2: error: ld returned 1 exit status

Compile testcase with 
-O3 -fvisibility=hidden -Werror=return-type -fvisibility-inlines-hidden
Comment 1 Andrew Pinski 2014-08-06 09:09:26 UTC
I don't see a bug here as there is one case where addSize can return 0 and with jump threading and basic block copying, we get a zero size passed to memset.
Comment 2 Alan Modra 2014-08-06 09:52:01 UTC
I can see where you're coming from Andrew, but what is disconcerting about this is that the _FORTIFY_SOURCE warning is plainly incorrect here.  How is one supposed to write a string.h memset macro using __builtin_constant_p() to provide a useful _FORTIFY_SOURCE warning, in the face of this sort of optimisation?

Users are going to see this as "__builtin_constant_p() is broken".
Comment 3 Andrew Pinski 2014-08-06 15:30:34 UTC
(In reply to Alan Modra from comment #2)
> I can see where you're coming from Andrew, but what is disconcerting about
> this is that the _FORTIFY_SOURCE warning is plainly incorrect here.  How is
> one supposed to write a string.h memset macro using __builtin_constant_p()
> to provide a useful _FORTIFY_SOURCE warning, in the face of this sort of
> optimisation?


This is why Jakub moved it to the front-end away from glibc (See PR 61294).

> 
> Users are going to see this as "__builtin_constant_p() is broken".

It is not.  It is working correctly as on that path, it is constant.

This is an exact duplicate of bug 61294 really.

*** This bug has been marked as a duplicate of bug 61294 ***