This is not really a reasonable physical situation. The problem is that if the resistance truly is zero then the charge time is also zero and the current is infinite, which is not a reasonable conclusion. In physical cases, something must give: the resistance of the wires, or the internal resistance of the battery, will cease to be negligible before that point.
The proper way to deal with negligible resistances is to work the problem out in full with a nonzero resistance, get a final answer, and then take the limit of $R\to0$. (Note that in many cases this is done backwards in front of students: one starts with negligible resistance and then builds up to the full case. This is justified in the cases where the full case does reduce to the simplified one.) In this particular case, the dissipated energy does not depend on $R$, and this should be read precisely like that:
no matter how small the resistance is, it will always dissipate the same amount of heat.
This is because a smaller resistance gives a shorter charge time and therefore a higher current. In this particular instance, there is no way to connect to the case at $R=0$ - and that case does not make sense anyway.
You probably feel like I'm short-changing you by doing this. What if you made everything out of superconductors? Well, the internal resistance of the battery, which is a must in any chemical source, will get in the way. Indeed, no source of electrical current can provide a finite amount of charge in zero time.
Most basically, though, this is because it takes time for the electrons to get from the source to the capacitor. In the limit where this happens very fast, then you have imbalanced charges travelling and accelerating, and they must stop suddenly at the capacitor plates. As BMS pointed out in a comment, this will inevitably be accompanied by the emission of electromagnetic radiation. The bottom line of this is that there is no way to transiently charge a capacitor without wasting energy.
On the other hand, there is a way to charge a capacitor such that all the energy spent by the battery is stored in the capacitor, and that is by doing it slowly instead of suddenly. That is, you increase the voltage of the battery adiabatically in lots of little steps $\Delta V$, and waiting a time $\tau\gg RC$ between steps so that the voltages will equilibrate. I will leave the precise details to you, but it turns out that in the limit of slow charging (i.e. $\tau/RC\to\infty$) no energy is wasted by the resistor. Finally, it is fairly easy to see that increasing the voltage slowly will mean the energy delivered by the current source will now be $\tfrac12 QV$, as one now traces a triangle instead of a square in the $(Q,V)$ plane.