  For optical waveguides with a layered background which itself is a slab
waveguide, a guided mode is a bound state in the continuum (BIC), if it
coexists with slab modes propagating outwards in the lateral direction; i.e.,
there are lateral leakage channels. It is known that generic BICs in optical
waveguides with lateral leakage channels are robust in the sense that they
still exist if the waveguide is perturbed arbitrarily. However, the theory is
not applicable to non-generic BICs which can be defined precisely. Near a BIC,
the waveguide supports resonant and leaky modes with a complex frequency and a
complex propagation constant, respectively. In this paper, we develop a
perturbation theory to show that the resonant and leaky modes near a
non-generic BIC have an ultra-high $Q$ factor and ultra-low leakage loss,
respectively. We also show that a merging-BIC obtained by tuning structural
parameters is always a non-generic BIC. Existing studies on merging-BICs are
concerned with specific examples and specific parameters. We analyze an
arbitrary structural perturbation (to a waveguide supporting a non-generic BIC)
given by $\delta F({\bf r})$, where $F({\bf r})$ is the perturbation profile
and $\delta$ is the amplitude, and show that the perturbed waveguide has two
BICs for $\delta>0$ (or $\delta<0$) and no BIC for $\delta<0$ (or $\delta>0$).
This implies that a non-generic BIC is a merging-BIC (for any perturbation
profile $F$) when $\delta$ is regarded as a parameter. Our study indicates that
non-generic BICs have interesting special properties that are useful in
applications.
