Both are carbohydrates. Both of these are not harmful in themselves. If you do not get carried away. In general, observe the measure and live in pleasure ;-)
And I would call flour flour more harmful: nowadays, finely ground white flour is widely used in baking, in which there is almost nothing but gluten. It takes longer to digest pure sugar, loading the digestive tract and sending carbohydrates into the blood. If we talk about bread and rolls, then thermophilic yeast and all kinds of improvers, also of dubious naturalness and benefits, are also added there. According to my feelings, flour products "clog" the stomach for a long time, they are viscous, sour, etc. I think, if you have to choose, it's better to gobble up a caramel or marshmallow than a bun. And if you choose from flour, then give preference to coarse flour and sourdough bread.
I would bet on a sweet, because it is more harmful - not only overweight, but also the potential acceleration of the development of diabetes, potential problems with teeth and skin.
It depends on how much. If there is something flour, that is sweet, absolutely uncontrollable, then the harm will be equivalent. This is with almost any product, so there must be a balance.