[Bug tree-optimization/72787] New: Query related to gcc-4_6-branch fix for Bug-49279 (Getting issue with __restrict type qualifier)
ranjan.winner at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Aug 3 12:14:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72787
Bug ID: 72787
Summary: Query related to gcc-4_6-branch fix for Bug-49279
(Getting issue with __restrict type qualifier)
Product: gcc
Version: 4.6.3
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: ranjan.winner at gmail dot com
Target Milestone: ---
Created attachment 39051
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39051&action=edit
Test Case
Question : Why for gcc-4.6 changes with tree-ssa.c file are omitted, I am
facing problem due to this omission.
Link:- https://gcc.gnu.org/ml/gcc-patches/2011-10/msg00468.html
Below is the link of patch submitted for gcc-4.7 branch
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=2453d677b3879f218c98812c82c2ca1b2494f694
While below is link for gcc-4.6 branch:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=479c60cd6e28540b9af9e0c436921ef23492a06a
Getting issue with gcc-4.6.3 version relating to __restrict qualifier.
While the issue is getting fix for gcc-4.8.1, the patch for both branches are
same, except for gcc-4_6-branch where change in file "gcc/tree-ssa.c" is not
considered as:
/* Do not lose casts to restrict qualified pointers. */
- if ((TYPE_RESTRICT (outer_type)
- != TYPE_RESTRICT (inner_type))
- && TYPE_RESTRICT (outer_type))
- return false;
But if we consider this change then issue is getting resolve with gcc-4.6.3
1) FOR GCC-4.6.3
$ ./x86_64-ran-linux-gcc --version
x86_64-ran-linux-gcc (GCC) 4.6.3
$ ./x86_64-ran-linux-gcc -Wall -O2 -g test_restrict.c -o test_restrict
$ ./test_restrict.c
Case 1: dst size (100) is less than len (12800) //Incorrect Result
Dest size is 12800 and len is 12800.
2) FOR GCC-4.8.1
$ ./x86_64-ran-linux-gcc --version
x86_64-windriver-linux-gcc (GCC) 4.8.1
$ ./x86_64-ran-linux-gcc -Wall -O2 -g test_restrict.c -o test_restrict
$ ./test_restrict
Case 2: dst size (12800) is equal to or greater than len (12800) //Incorrect
Result
Dest size is 12800 and len is 12800.
-----------------TESTCASE-------------
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define DIMENSION_1 128
#define DIMENSION_2 100
char a[DIMENSION_1][DIMENSION_2];
char b[DIMENSION_1][DIMENSION_2];
extern inline __attribute__ ((always_inline)) int
my_memcpy(void *__restrict dst, const void *__restrict src, size_t len)
{
size_t _sz = __builtin_object_size(dst, 1);
return (((_sz != (size_t) -1) && (_sz != 0))
? ((_sz < len)
? printf("Case 1: dst size (%zu) is less than len (%zu)\n", _sz, len)
: printf("Case 2: dst size (%zu) is equal to or greater than len
(%zu)\n", _sz, len))
: printf("Case 3: dst size is (%zu) and len is (%zu)\n", _sz, len));
}
int main(int argc, char **argv)
{
my_memcpy(&a, &b, (DIMENSION_1*DIMENSION_2));
printf("Dest size is %zu and len is %u.\n",
__builtin_object_size(&a, 1), DIMENSION_1*DIMENSION_2);
return 0;
}
More information about the Gcc-bugs
mailing list