Weird (!) gcc (g++) compile error

This is a discussion on Weird (!) gcc (g++) compile error within the C++ Programming forums, part of the General Programming Boards category; When I compile my program I get this: internal error--insn does not satisfy its constraints: (insn 105 48 49 (set ...

  1. #1
    Skarr
    Guest

    Weird (!) gcc (g++) compile error

    When I compile my program I get this:

    internal error--insn does not satisfy its constraints:
    (insn 105 48 49 (set (reg:SI 4 %esi)
    (reg:SI 31)) 48 {movsi+2} (nil)
    (nil))

    I've looked in the source for gcc, and this comes from toplev.c... is it my program or is it a bug?

    Oh, and btw, I'm using gcc 2 something (the one that comes with FreeBSD 4.5)

    Thanks

    Skarr

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    Wow, that is odd. I don't know whether it's a compiler bug or not. Is it some huge source file producing the error? Or is it something manageable that we can take a look at?
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  3. #3
    Skarr
    Guest

    Source code

    It's nothing big, and it really should work:

    #include <curses.h>

    class SMap {
    public:
    ~SMap(void);
    void blend(SMap &);
    char map[COLS][LINES];
    };

    void SMap::blend(SMap &smap) {

    for (int a = 0; a < COLS; a++)
    for (int b = 0; b < LINES; b++)
    if (smap.map[a][b] != map[a][b])
    smap.map[a][b] = map[a][b];

    }

    Try it out, and if it does work, what version of gcc are you using?

    Note: This is from my memory. I'll check it as soon as possible.

  4. #4
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    It seems curses already defines LINES and COLS as non-constant ints. The following code works when USE_CURSES is not defined, (thus using the constsants for COLS and LINES). If USE_CURSES is defined (hence including curses.h) and using the non-const int definition of COLS and LINES, it is illegal. I know nothing about curses, however. Are you trying to make map a 2d array of a size that varies at compile time? If so, you need to use dynamic memory.

    Code:
    // #define USE_CURSES
    
    #ifdef USE_CURSES
    #include <curses.h>
    #else
    const int COLS=5;
    const int LINES=5;
    #endif
    
    class SMap {
     public:
     ~SMap(void);
     void blend(SMap &);
     char map[COLS][LINES];
     };
     
    void SMap::blend(SMap &smap) {
    
    for (int a = 0; a < COLS; a++)
     for (int b = 0; b < LINES; b++)
     if (smap.map[a][b] != map[a][b])
     smap.map[a][b] = map[a][b];
     
    }
     
    int main() {
    	return 0;
    }
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 11:17 AM
  2. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 01:17 AM
  3. file reading
    By gunghomiller in forum C++ Programming
    Replies: 9
    Last Post: 08-07-2007, 11:55 PM
  4. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 12:54 PM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21