You can analyze how projections of the boxes onto the axes intersect with each other (similarly to @coproc's answer). But this time calculate the "vector" size of each intersection and then check if all are non-negative. Then to check for corners-only-touching you can request that at least one such length is positive. For example, with something like this (I have rearranged the bounding box structure for clarity):
typedef int axis_t; // some signed type
struct range { axis_t low, high; };
struct box { range x, y; }
axis_t overlap(const range &a, const range &b)
{
return min(a.high, b.high) - max(a.low, b.low);
}
bool overlap(const box &a, const box &b)
{
axis_t x_overlap = overlap(a.x, b.x);
axis_t y_overlap = overlap(a.y, b.y);
return x_overlap >= 0 && y_overlap >= 0 && x_overlap + y_overlap > 0;
}
This is up-to 7 comparisons and 3 additions/subtractions, but there are 8 values to consider, so probably it's not that bad.