Sugar is an organic molecule (based on carbon) just like the components of cannabis. Burning ANYTHING creates carbon dioxide and carbon monoxide (and water). What did you think smoke was? Don't smoke sugar though, it doesn't impart any flavor on the smoke.