Thread: warning:internal error

  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    3

    warning:internal error

    hello.I am getting warnings called " warning:internal errorut of range error" when i built the program which is a mixture of c and assembly language. A part of it where i am getting the warning is given below

    Code:
    unsigned char lookup()
    {
    int i,j;
    int k=0;
    int index[num_d];
    float dif[num_d];
    ...
    ...
    for(i=0;i<num_d;i++)
    {
    if(dif[i]<0.01)....warning:internal error:out of range error
    {
    index[k++]=i;
    }
    }
    
    so wherever there is use of array i am getting this warning and also in the lines given below
    
    void anl(int xx)
    {
    p1=fir1(xx,p1);....same warning
    p2=fir2(xx,p2);....same warning
    }
    
    
    unsigned char min(float a[num_d])
    {
    float smallest;
    unsigned char ii;
    unsigned char index;
    
    index =0;
    smallest = a[0];
    
    for(ii=1;ii<num_d;ii++)
    {
    if(a[ii]<smallest).......warning-internal error:out of range error
    {
    smallest=a[ii];
    index = ii;
    }
    }
    
    index++;
    return index;
    }
    
    float calcorrelation(int a[size_dic], int b[size_dic])
    {
    int ii;
    float meanx1=0;
    float r;
    for (ii=0; ii<size_dic; ii++)
    {
    meanx1 = meanx1 + fix2float(a[ii]);.............///warning-out of range
    
    }
    r=size_dic*meanx1;...........same warning
    
    r=1-r;
    }
    
    if (r < 0).......................////warnin-out of range
    {
    r = -r;
    }
    return r;
    can someone plz help me..

  2. #2
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    Comparing floating point variables is, I think, causing the problem. Try appending 'f' to make it a float for eg.
    Code:
    if(dif[i]<0.01f);
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Post something small, COMPLETE and without any of your .... paraphrasing the problem.

    If you want to highlight a specific line, then put something like
    /* error foo on this line */

    You also need to say WHICH compiler you're using.
    Good compilers rarely barf on simple programs with an "internal error" message. That means your compiler is broken, not necessarily your code.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    What is num_d? If it's not a constant, then your code is wrong (this is allowed in C++0x, not in C/C++). Because the size of the array isn't known at compile time. It would be a horrible error message should this be true, though.

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    C++0x does not allow non-constant array sizes to my knowledge...
    And it is supported in C99.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Jul 2009
    Posts
    3
    ok.Below i have given a portion of problem

    Code:
    #define num_dic 5
    #define size_dic 40
    Main(void)
    {
       unsigned char ii;//[0-256]
       int jj,kk=0;
       unsigned char result,temp;
       float  differ[num_dic];
       int  tmp_array[size_dic];
       float diffeuclid[num_dic];
       unsigned char rangeindex[num_dic];   // store the code with large coefficients
       
       for (ii=0;ii<num_dic;ii++)
       {
         differ[ii]=0.0;      
         diffeuclid[ii]=0.0;
       }
       
       for( ii=0; ii < num_dic; ii++ ) 
       {                             
          for(jj=0;jj<size_dic;jj++)
          {
              tmp_array[jj]=dic[ii][jj];
          }
          differ[ii]=calcorrelation(tmp_array, word);
          
       }                
           
               
       for(ii=0; ii<num_dic;ii++)
       {
           if(differ[ii]<0.01)  /*warning:internal error-out of range error*/
           { 
            rangeindex[kk++]=ii;
           } 
       }                            
    }            
          
    
    float calcorrelation(int a[size_dic], int b[size_dic])
    { 
        int ii;
        float meanx1=0, meanx2=0, meanxy=0, meany1=0, meany2=0;
        float r;
        for (ii=0; ii<size_dic; ii++)
        {
            meanx1 = meanx1 + fix2float(a[ii]);  )  /*warning:internal error-out of range error*/
    
            meanx2 = meanx2 + fix2float(a[ii])*fix2float(a[ii]); )  /*warning:internal error-out of range error*/
    
            meany1 = meany1 + fix2float(b[ii]); )  /*warning:internal error-out of range error*/
    
            meany2 = meany2 + fix2float(b[ii])*fix2float(b[ii]); )  /*warning:internal error-out of range error*/
    
            meanxy = meanxy + fix2float(a[ii])*fix2float(b[ii]); )  /*warning:internal error-out of range error*/
    
        }
        
        if (((size_dic*meanx2-meanx1*meanx1)==0) && ((size_dic*meany2-meany1*meany1)==0) ) )  /*warning:internal error-out of range error*/
    
           r = 0;
        else 
        {    
           r=(size_dic*meanxy-meanx1*meany1)*(size_dic*meanxy-meanx1*meany1)/(size_dic*meanx2-meanx1*meanx1)/(size_dic*meany2-meany1*meany1) )  /*warning:internal error-out of range error*/
    ;
           r=1-r;
        }     
          
        if (r < 0) )  /*warning:internal error-out of range error*/
    
        {
             r = -r;
        }
        return r;
    }

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Is this your real code?
    You have a lot of mismatched ( and ), and ; placed at wrong places.
    And main returns int. Not nothing.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by skb_mys View Post
    hello.I am getting warnings called " warning:internal errorut of range error" when i built the program which is a mixture of c and assembly language.
    Notice the part where it says internal error? The problem is not your code, but the compiler's ability to handle it. Basically, your compiler sucks.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Yes, get yourself a new compiler while you're at it.
    List of some IDEs
    Assuming you're on Windows, I would recommend Visual Studio.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > Main(void)
    main is also in lower case.

    And you STILL didn't mention which compiler you're using.

    It's not Miracle-C by any chance is it?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  11. #11
    Registered User
    Join Date
    Jul 2009
    Posts
    3
    Hmmm.Sorry its a big program.I just gave a small portion of program.So while 'cut and paste and modify' operation a few 'so called miracles' peeped in. I am working on avr microcontroller and am using AVR STUDIO 4.16.So is the problem with the compiler.?will it affect the desired output..?

  12. #12
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > Sorry its a big program.I just gave a small portion of program.
    Like I said earlier, the ACTUAL code which generates the problem.

    Do NOT post the whole program. Make a copy, and start deleting lots of code away from the error messages until you get down to a SMALL AND COMPLETE program which still generates the error message.

    It could be anything which causes those errors. Maybe for example, you have ALL the code in some massive single source file, and these are a few lines right at the end of the file.

    When you have your nice short file, you can then raise a bug report with the maintainer of the compiler.

    If you do have a single large source file, and making it smaller allows it to compile, then you need to split your code up into multiple source files.

    I'm also assuming that since you said "big program" that it actually worked OK just recently, and that you made some unrelated change (say adding another function), and now you're getting these errors in code which used to work.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM