Small prob in juce_PNGLoader.cpp


#1

Hi Jules,

the juce_loadPNGImageFromStream () function is defined as throw(), so it cannot throw/catch exceptions later in the try-catch block. Throw() doesn’t do much anyway, at least with VC, so maybe it can be “thrown out”.


#2

As I understood it, making a method “throw()” doesn’t stop you using exceptions inside it, it just means that it won’t throw any itself, right?

(An in fact, throw() does have a very big effect in VC - when I first went through and added it to all the simple methods in the library, the demo executable shrank by about 20%!)


#3

[quote=“jules”]As I understood it, making a method “throw()” doesn’t stop you using exceptions inside it, it just means that it won’t throw any itself, right?

[/quote]

TBH, I’m not sure. But my VC9 complains that the catch block is unreachable.


#4

That’s odd, I’ve never seen that in VC2009… Which block exactly does it complain about?


#5

Both, actually. I get 3 warning messages (C4702: unreachable code) for all three lines in the 2 catch blocks.


#6

Well, that’s not because the outer function is declared throw(), it’ll be because the blocks only contain calls to C functions. Funny thing is, I must have put them in because of some sort of crash I’d seen in the png code, so that’s all a bit puzzling…


#7

Okay, that may be. The good thing is that you know about it :slight_smile:


#8

It’s not a big deal at all, though I always prefer to avoid compiler warnings if possible.