Apparent paradox regarding spontaneity Consider the following analysis ( rev and irrev respectively refer to a reversible and an irreversible path, between the same initial and final states):
$dU_{rev}=dq_{rev}+dw_{rev}$,and,$dU_{irrev}=dq_{irrev}+dw_{irrev}$.
$dU_{rev}=dU_{irrev}$. Therefore, $dq_{rev}+dw_{rev}=dq_{irrev}+dw_{irrev}$. Rearranging,
$$dq_{irrev}-dq_{rev}=dw_{rev}-dw_{irrev}\tag{E01}$$
Now: If the volume increases, then $dw_{rev}$ and $dw_{irrev}$ are negative: with $|dw_{rev}|&gt;|dw_{irrev}|$. Thus $dw_{rev}-dw_{irrev}&lt;0$.
On the other hand, if the volume decreases, then $dw_{rev}$ and $dw_{irrev}$ are positive: with $|dw_{rev}|&lt;|dw_{irrev}|$. Thus, again, $dw_{rev}-dw_{irrev}&lt;0$.
We can thus conclude, in general, $dw_{rev}-dw_{irrev}&lt;0$. E01 thus becomes:
$$dq_{irrev}-dq_{rev}&lt;0\tag{E02}$$
Now the Gibbs free energy (G) is defined as $G=H-TS$. Thus, $dG=dH-TdS-SdT$. At constant pressure and Temperature, $dH=dq$ and $dT=0$. Thus,
$$dG=dq-TdS= dq-T(dq_{rev}/T)=dq-dq_{rev}\tag{E03}$$
If the process is reversible , then E03 becomes $dG=0$. If the process is irreversible, E02 implies $dG&lt;0$. Combining these together, we get $dG \leq0$.
This analysis ensures that $dG$ is never positive...... Which seems to suggest that (if we take $dG$ as the criteria for spontaneity) every process is spontaneous.
The logical conclusion is that there's something in my analysis that isnt general: it holds for spontaneous processes only. What is it? Is it that the first-law requires some modification to be general?
The problem is that you are starting the derivation from conditions that ensure reversibility or spontaneity, but you are not considering conditions that lead to the third possibility.
The following expression from your post is generally true:
$dq-dq_{rev}=dw_{rev}-dw $
I've dropped the &quot;irreversible&quot; labels and assume that $dq$ and $dw$ refer to some process that you have dreamed up.
Now the condition that leads to non-spontaneous processes must be
$dw_{rev}-dw&gt;0$
since you have shown that the other conditions are for spontaneous processes, which leads to
$dq−dq_{rev}&gt;0$
and therefore
$dG&gt;0$
which is what you are looking for.
If you forget about $dG$ for a second and focus on  how you can get to the equation $dq−dq_{rev}&gt;0$ (since you already showed the next step to an inequality in terms of $dG$), you see that to arrive at this equation you have to say that the system can do more work in a process you dreamed up than in a reversible process  ($dw_{rev}-dw&gt;0$), which violates the 2nd law. To carry out a process in which $dG&gt;0$, you have to correct this violation and make up the work difference by having the surroundings do additional (more) work on the system than was assumed in the original analysis.
By the way, you should be careful using PV-work in your examples, as for an ideal gas in the absence of reactions, Boyle's law says that the pressure will change during an isothermal expansion and Charles' law says that the temperature changes in an isobaric process. In neither case would the Gibbs free energy provide the criterion for spontaneity.