LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-27-2015, 10:02 AM   #1
chakka.lokesh
Member
 
Registered: Mar 2008
Distribution: Ubuntu
Posts: 270

Rep: Reputation: 33
gcc compilation error: vector shuffling operation will be expanded piecewise


i have written a piece of code as follows:

Code:
char my_ex_or_function( char *ptr )
{
        char ex_or = 0;
        int i;

        for( i=0; i<10000; i++ )// ptr will be pointing to fixed block of size 10000
                ex_or ^= ptr[i];
        return ex_or;
}
while compiling above code, I am seeing following error:

cc1: error: vector shuffling operation will be expanded piecewise [-Werror=vector-operation-performance]

I referred this link
but my requirement is to do XOR.

As I am treating the warnings also as errors, I am seeing compilation is failing.
I am using gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2)
can some one help me how to fix this warning ?
 
Old 10-27-2015, 10:28 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,849

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
probably because you passed a pointer and used an array. Try to use pointer instead of index.
Code:
        p = ptr;
        for( i=0; i<10000; i++ ) {// ptr will be pointing to fixed block of size 10000
                ex_or ^= *p;
                p++;
        }
        return ex_or;
or use: char ptr[10000] instead of pointer
 
Old 10-28-2015, 10:03 AM   #3
chakka.lokesh
Member
 
Registered: Mar 2008
Distribution: Ubuntu
Posts: 270

Original Poster
Rep: Reputation: 33
pan64,

thanks for your reply. I tried both the ways you suggested.
still seeing same problem.
 
Old 10-28-2015, 11:20 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,863
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
You might have used some exotic compiler-option having something to do with vector-operations (eg: -Wvector-operation-performance).

Note: hard-coding this number is impractical, try to be more flexible:

Code:
char my_ex_or_function (int n, const char *ptr)
{
    char ex_or = 0;
    int i;

    for (i=0; i<n; i++ ) {
        ex_or ^= ptr[i];
    }
    return ex_or;
}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gcc compilation error tyaginitish1448 Linux - Software 7 05-04-2012 10:01 AM
gcc 4.4.3 compilation error pankajd Linux - Software 1 04-03-2010 09:50 AM
gcc (GCC) 4.3.2 20081105 (Red Hat 4.3.2-7) compilation error adhesh_19 Red Hat 0 01-05-2010 05:34 AM
have gcc compilation error during gcc installtion in linuxfromscratch vbshanmugaprakash Linux - General 3 12-13-2006 05:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration