3

So i'm trying to use case range with enums, but i get this weird error

internal compiler error: Segmentation fault
case SectionOrder::CREATE_GAME_MAP_1 ... SectionOrder::CREATE_GAME_MAP_10:
^~~~~~~~~~~~~~~~~~
libbacktrace could not find executable to open
Please submit a full bug report, with preprocessed source if appropriate.
enum class SectionOrder{
    CREATE_GAME_MAP_1 = 1,
    CREATE_GAME_MAP_2,
    CREATE_GAME_MAP_3,
    CREATE_GAME_MAP_4,
    CREATE_GAME_MAP_5,
    CREATE_GAME_MAP_6,
    CREATE_GAME_MAP_7,
    CREATE_GAME_MAP_8,
    CREATE_GAME_MAP_9,
    CREATE_GAME_MAP_10,
};

int main(){
    SectionOrder x = SectionOrder::CREATE_GAME_MAP_1;

    switch(x){
        case SectionOrder::CREATE_GAME_MAP1 ... SectionOrder::CREATE_GAME_MAP2:
           break;
    }
}
273K
  • 29,503
  • 10
  • 41
  • 64
  • 1
    You know `case` ranges are not in the standard C++, right? But you still should report this as a compiler bug, assuming it reproduces on the latest version. – HolyBlackCat Aug 30 '22 at 21:55
  • @HolyBlackCat yeah i'm using mingw64 latest version with -std=c++17, but what do you mean with "case ranges are not in the standart C++" ? – Aytunç Demir Aug 30 '22 at 21:56
  • They're a gcc extension. I think clang has them too, but they're not standard, you won't find them in the language definition anywhere. – Paul Sanders Aug 30 '22 at 22:06
  • 1
    Well, nothing much you can do about the segfault: congratulations, you found a compiler bug! – Sam Varshavchik Aug 30 '22 at 22:07
  • 1
    `error: no member named 'CREATE_GAME_MAP1' in 'SectionOrder'; did you mean 'CREATE_GAME_MAP_1'?` – 273K Aug 30 '22 at 22:08
  • @SamVarshavchik But OP can work around it, of course. – Paul Sanders Aug 30 '22 at 22:09
  • @273K yeah my mistake i'm sorry, but the problem is not name conflict in my program, what did you get after you fixed the name error ? – Aytunç Demir Aug 30 '22 at 22:13
  • @SamVarshavchik omg i'm so happy haha i found my first compiler bug – Aytunç Demir Aug 30 '22 at 22:14
  • 1
    Pro tip: if you run a compiler, and it crashes with a "segmentation fault" it's always a compiler bug. – Sam Varshavchik Aug 30 '22 at 22:15
  • *omg i'm so happy haha i found my first compiler bug* You may be not a first finder. What is the compiler version? It should be shown in the error message. – 273K Aug 30 '22 at 22:17
  • @273K g++.exe (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0 – Aytunç Demir Aug 30 '22 at 22:19
  • 8.1.0 is too old. Use the newer one, 12.2.0 https://www.msys2.org/ – 273K Aug 30 '22 at 22:24
  • Does this answer your question? [How do I select a range of values in a switch statement?](https://stackoverflow.com/questions/9432226/how-do-i-select-a-range-of-values-in-a-switch-statement) – The Dreams Wind Aug 30 '22 at 22:52
  • @TheDreamsWind That looks like [what OP tried](https://godbolt.org/z/139Eq5PGG) doing so I don't think that'll answer the question. The problem isn't with OPs code but with the ICE. – Ted Lyngmo Aug 31 '22 at 17:36

0 Answers0