I like to carry PowerBars, because they taste sufficiently foul that I'm never tempted to eat them just because I'm bored or peckish. Which means they're there when I really need them. The expiry date printed on them seems to be imaginary, I've eaten them when the foil wrapper is intact but so worn that it's hard to make out what flavour the bar is supposed to be. One subtle advantage is that they're flexible, so you can wedge them into a corner of a bag and they'll conform to the space available. I often shove one in with the rain cover on my backpack and camera bag, so if you carry a rain jacket you could probably put one in that.
In my experience carrying sugar is a waste of time - it just causes insulin surges and makes the whole experience less pleasant. I go from hungry to hyper to hypo to wondering what I just did to myself.
Shopping hint: In response to Daniel R Hicks' comment above, if I'm shopping at a generic chain store that seems to have what I want, I'll buy one each of the more likely options and eat them over the next few days. Or open them, taste them, and bin them if they're not at all what I want. When I find one I like I'll buy 10 or more of them, ignoring the shelf life, and just eat one a ear or so later to make sure they're still edible.
They're manufactured as effectively sterile bar, and they're so energy-dense that anything growing in there will have a hard time unless the package opens and water gets in. Honey and jam work exactly this way - the high sugar content and low water content means anything that tries to grow has the water stripped out of it and it dies.
That's why I still have a stock of powerbars that are probably 10 years old, and I'm not sure how many I have because when I bought a bunch ten years ago I stashed them all through my camping/hiking/touring gear and they still turn up from time to time. It's easy to find an inconspicuous place to carry something, but that also makes it easy to forget when unpacking :)