public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Hariharan Sandanagobalane <hariharans@picochip.com>
To: gcc-help@gcc.gnu.org
Subject: GCC vector extensions.
Date: Thu, 04 Nov 2010 16:14:00 -0000	[thread overview]
Message-ID: <4CD2DBC3.9040809@picochip.com> (raw)

Hello,
I have a feeling the website is wrong. If you went to 
http://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html, it claims

"In C vectors can be subscripted as if the vector were an array with the 
same number of elements and base type. Out of bound accesses invoke 
undefined behavior at runtime. Warnings for out of bound accesses for 
vector subscription can be enabled with -Warray-bounds. "

I went through the gcc source code and the extend.texi does not have 
this statement anymore. Why is that not reflected on the website?

When i tried that in a simple example.

#define vector __attribute__((vector_size(16) ))

static inline vector int vectadd(vector int t1, vector int t2)
{
  return t1 + t2;
}

vector int a = {0, 1, 0, 1, 0, 0, 0, 0};
vector int b = {0, 0, 1, 1, 0, 0, 0, 0};
vector int c = {0, 1, 1, 0, 0, 0, 0, 0};
int main(void)
{
   vector int a0;
   a0 = vectadd(a, b);
   if (a0[2] != 1)
     __builtin_abort ();
   return 0;
}

I get a compiler error "error: subscripted value is neither array nor 
pointer".

Cheers
Hari

             reply	other threads:[~2010-11-04 16:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-04 16:14 Hariharan Sandanagobalane [this message]
2010-11-04 18:59 ` Ian Lance Taylor
  -- strict thread matches above, loose matches on Subject: below --
2011-02-28 23:37 Gcc " Hari Sandanagobalane
2011-02-28 23:55 ` Ian Lance Taylor
2006-04-07 19:03 GCC Vector Extensions Christian Schoenebeck
2006-04-07 20:16 ` Greg Buchholz
2006-04-15  0:58   ` Christian Schoenebeck
2006-04-18 10:04     ` Andrew Haley
2006-04-18 23:38       ` Christian Schoenebeck
2006-04-19  8:30         ` Andrew Haley
2006-04-19 12:19           ` Christian Schoenebeck
2006-04-19 13:13             ` John Love-Jensen
2006-04-19 14:03             ` Andrew Haley
2006-04-19 15:20               ` Andrew Haley
2006-04-19 20:05                 ` Christian Schoenebeck
2006-04-19 20:25                   ` Andrew Haley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CD2DBC3.9040809@picochip.com \
    --to=hariharans@picochip.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).