On Tue, Jun 29, 2021 at 12:47:07AM +0200, Mark Wielaard wrote: > On Tue, Jun 29, 2021 at 12:06:56AM +0200, Marc wrote: > > Hi, > > > > > Translating the AST LifetimeType to the HIR LifetimeType causes a warning: > > > warning: ‘ltt’ may be used uninitialized > > > > Was wondering why this is needed as the switch case covers all enum > > variants, how can ltt be uninitialized ? I have the same fix locally but > > was thinking something else was causing the error... > > LifetimeType is a plain enum, which aren't really their own types, > they are really just ints with fancy names. We could make them enum > class, which is a strong type. Then the compiler would know the switch > really covers all enum (class) variants. But then we have to provide > the right scope/type everywhere we use them in the code (which might > be a good idea, but is more typing).
I just tried to make LifetimeType an enum class and that doesn't help. So I was wrong. I don't know why the compiler doesn't see this? It should know since if not all switch cases were covered, -Wswitch (enabled by -Wall) gives us a warning... So, I don't fully understand why gcc needs the default gcc_unreachable case. It is what is used in the rest of the code though. Cheers, Mark -- Gcc-rust mailing list Gcc-rust@gcc.gnu.org https://gcc.gnu.org/mailman/listinfo/gcc-rust