| Summary: | __builtin_memcpy code generation problem | ||
|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | m0459129523 |
| Component: | gcc | Assignee: | Jakub Jelinek <jakub> |
| Status: | CLOSED NOTABUG | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 16 | CC: | jakub |
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2011-12-27 08:50:38 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
memcpy (0, p, 256); is undefined behavior at runtime, therefore gcc is free to insert there any kind of code it likes. The parameters to main are not valid C either. ccp optimizes away even memcpy calls that don't trigger undefined behavior (just implementation defined behavior). Tracking that as PR51683 upstream. |
Description of problem: gcc on Fedora 16 fails to generate "memcpy" code when compiling a function calling a static inline function containing __builtin_memcpy with an immediate value as the destination argument. Version-Release number of selected component (if applicable): gcc-4.6.2-1.fc16.x86_64 How reproducible: always Steps to Reproduce: 1. compile the following function with "gcc -O -S" ---- static inline void *cp(void* d,void* s,int l) { return __builtin_memcpy(d,s,l); } void main(void *p) { cp(0,p,256); } ---- When we change to "cp(p,0,256)", it generates expected code. Actual results: ... main: .LFB1: .cfi_startproc rep ret .cfi_endproc .LFE1: ... Expected results: ... main: .LFB1: .cfi_startproc movq %rdi, %rdx movl $0, %esi movl $256, %eax (code for memcpy) ... Additional info: