Bug 240819
Summary: | GCC miscompiles heavily inlined code at -O2 | ||||||
---|---|---|---|---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | James Antill <james.antill> | ||||
Component: | gcc | Assignee: | Jakub Jelinek <jakub> | ||||
Status: | CLOSED NOTABUG | QA Contact: | |||||
Severity: | high | Docs Contact: | |||||
Priority: | high | ||||||
Version: | 6 | ||||||
Target Milestone: | --- | ||||||
Target Release: | --- | ||||||
Hardware: | All | ||||||
OS: | Linux | ||||||
Whiteboard: | |||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | 2007-05-22 10:13:43 UTC | Type: | --- | ||||
Regression: | --- | Mount Type: | --- | ||||
Documentation: | --- | CRM: | |||||
Verified Versions: | Category: | --- | |||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
Cloudforms Team: | --- | Target Upstream Version: | |||||
Embargoed: | |||||||
Attachments: |
|
Description
James Antill
2007-05-22 00:07:43 UTC
Created attachment 155143 [details]
Tarball of GCC miscompiling problem, just type make check
That's not a GCC bug, but documented behavior. USTR_CONF_e_PROTO int ustrp__rw_realloc(void *, struct Ustr **, int, size_t, size_t) USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A(); where USTR__COMPILE_ATTR_NONNULL_A() expands to __attribute__((nonnull)). This means you say that the first and second arguments to the function must be non-null. `nonnull (ARG-INDEX, ...)' The `nonnull' attribute specifies that some function parameters should be non-null pointers. For instance, the declaration: extern void * my_memcpy (void *dest, const void *src, size_t len) __attribute__((nonnull (1, 2))); causes the compiler to check that, in calls to `my_memcpy', arguments DEST and SRC are non-null. If the compiler determines that a null pointer is passed in an argument slot marked as non-null, and the `-Wnonnull' option is enabled, a warning is issued. The compiler may also choose to make optimizations based on the knowledge that certain function arguments will not be null. If no argument index list is given to the `nonnull' attribute, all pointer arguments are marked as non-null. To illustrate, the following declaration is equivalent to the previous example: extern void * my_memcpy (void *dest, const void *src, size_t len) __attribute__((nonnull)); Especially note the 'The compiler may also choose'... sentence. With -O2 the compiler chose to take advantage of that guarantee (in VRP pass particularly), but at runtime you violated that promise. int ustrp__rw_realloc(void *, struct Ustr **, int, size_t, size_t) USTR__COMPILE_ATTR_WARN_UNUSED_RET() USTR__COMPILE_ATTR_NONNULL_A(); ...argghhh ... damn, I was looking for a screwup like that on the external functions, for some reason I didn't think about the internal ones. Sorry, and thanks Jackub. |