Bug 11942 - restrict is broken in C99 mode?
Summary: restrict is broken in C99 mode?
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.4.0
: P3 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-08-16 08:02 UTC by Debian GCC Maintainers
Modified: 2003-10-24 08:54 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-08-16 13:20:30


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2003-08-16 08:02:35 UTC
[forwarded from http://bugs.debian.org/187091]

Bug submitter writes:

When I compile certain files (a testcase is attached), gcc fails to
compile with the following error:
broken-restrict.c:23: invalid use of `restrict'
I am sure this is a valid use of restrict because I have seen it used in
<http://www.opengroup.org/onlinepubs/007904975/functions/lio_listio.html>
(SUSv3), which is aligned with C99. In fact, that page says, in part:

	The restrict keyword is added to the lio_listio() prototype for
	alignment with the ISO/IEC 9899:1999 standard.

You can compile this with:
"gcc -std=c99 -c broken-restrict.c" and it will break or you can use
"gcc -DRESTRICT_IS_BROKEN -std=c99 -c broken-restrict.c" and it will
work.

I've pretty much narrowed it down to the restrict in the brackets (if
you put them on a new line, you will see that they are the cause of the
syntax error).

-----------
/* See
 * <http://www.opengroup.org/onlinepubs/007904975/functions/lio_listio.html>
 * for SUSv3's description of lio_listio().
 */

/* This is based on lio_listio(). */

struct foo
{
        char *x;
};

struct bar
{
        int *x;
};

int foo_lio_listio(int mode,
#ifdef RESTRICT_IS_BROKEN
                struct foo *const list[],
#else
                struct foo *__restrict__
                        const list[__restrict__],  /* line 23 */
#endif
                int nent,
#ifdef RESTRICT_IS_BROKEN
                struct bar *sig)
#else
                struct bar *__restrict__ sig)
#endif
{
        return 0;
}
------
Comment 1 Andrew Pinski 2003-08-16 13:20:29 UTC
I can confirm this on the mainline (20030815).
Comment 2 Dara Hazeghi 2003-08-22 23:53:09 UTC
Not a regression (so not targetted for 3.4)
Comment 3 Joseph S. Myers 2003-10-24 08:54:57 UTC
Fixed on mainline, probably by
<http://gcc.gnu.org/ml/gcc-patches/2003-10/msg00693.html>.